From 592b4aca308230493ae07db06c86bd58042c45f4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 2 Apr 2011 18:14:16 -0700 Subject: [PATCH] Generated this project from the simple template. --- .gitignore | 2 + project/build.properties | 6 +- project/build/Libraries.scala | 61 --------------- project/build/Repositories.scala | 11 --- project/build/SbtTemplateProject.scala | 100 +++++++++++++++++++++++-- project/plugins/Plugins.scala | 7 ++ 6 files changed, 104 insertions(+), 83 deletions(-) delete mode 100644 project/build/Libraries.scala delete mode 100644 project/build/Repositories.scala create mode 100644 project/plugins/Plugins.scala diff --git a/.gitignore b/.gitignore index f72e594c9..721cc4ea1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +/SbtTemplateProject.scala target /project/boot +/project/plugins lib_managed src_managed /ext diff --git a/project/build.properties b/project/build.properties index eb8b9f777..df961e0db 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,8 +1,8 @@ #Project properties -#Generated by sbt-setup +#Generated by sbt-setup on Sat Apr 2 18:11:54 PDT 2011 project.organization=improving project.name=sbt-template -sbt.version=0.7.5.RC0 -project.version=0.1.1 +sbt.version=0.7.6.RC0 +project.version=0.0.1 build.scala.versions=2.8.1 project.initialize=false diff --git a/project/build/Libraries.scala b/project/build/Libraries.scala deleted file mode 100644 index b4f88544d..000000000 --- a/project/build/Libraries.scala +++ /dev/null @@ -1,61 +0,0 @@ -import sbt._ - -case class ArtifactRevision(revision: String) -case class ArtifactConfig(confs: String, fn: ModuleID => ModuleID) -object ArtifactConfig { - implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) -} - -trait LowPriorityLibraries { - self: DefaultProject => - - // "latest.integration", "latest.milestone", "latest.release" - def defaultRevision = "latest.integration" - protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) - // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - - protected implicit def autoConfig - (artifact: GroupArtifactID) - (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = - { - val ArtifactConfig(confs, fn) = config - fn( - if (confs == "") artifact % rev.revision - else artifact % rev.revision % config.confs - ) - } -} - -trait TestLibraries extends LowPriorityLibraries { - self: DefaultProject => - - private implicit val testDepConfig = ArtifactConfig("test", _.withSources) - val specs: ModuleID = "org.scala-tools.testing" %% "specs" - val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" -} - -trait Libraries extends Repositories with TestLibraries { - self: DefaultProject => - - import ArtifactConfig.defaultArtifactConfig - - // val ant: ModuleID = "org.apache.ant" % "ant" - // val asmAll: ModuleID = "asm" % "asm-all" withSources() - // val easymock: ModuleID = "org.easymock" % "easymock" - // val guava: ModuleID = "com.google.guava" % "guava" - // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() - // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" - // val jmock: ModuleID = "org.jmock" % "jmock" - // val jodaTime: ModuleID = "joda-time" % "joda-time" - // val liftJson: ModuleID = "net.liftweb" %% "lift-json" - // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" - // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" - // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() - // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() - // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() -} diff --git a/project/build/Repositories.scala b/project/build/Repositories.scala deleted file mode 100644 index 25fd2037d..000000000 --- a/project/build/Repositories.scala +++ /dev/null @@ -1,11 +0,0 @@ -import sbt._ - -trait Repositories { - self: DefaultProject => - - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" - val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" -} diff --git a/project/build/SbtTemplateProject.scala b/project/build/SbtTemplateProject.scala index 00038b02c..51c078369 100644 --- a/project/build/SbtTemplateProject.scala +++ b/project/build/SbtTemplateProject.scala @@ -1,11 +1,95 @@ import sbt._ -class SbttemplateProject(info: ProjectInfo) extends DefaultProject(info) with Libraries { - // -Dscala.local=/path/to/scala/build - override def localScala = System.getenv("scala.local") match { - case null => super.localScala - case path => - log.info("Found scala.local: " + path) - List(defineScala("2.9.0-local", new java.io.File(path))) - } +class SbtTemplateProject(info: ProjectInfo) extends DefaultProject(info) with ProjectSupport { + +} + + +trait ProjectSupport extends ModuleIdDynamifactory { + self: DefaultProject => + + /** Default "dynamic revision" to use with ivy. + * See [[http://www.jaya.free.fr/ivy/doc/ivyfile/dependency.html]]. + * Likely alternatives: latest.milestone, latest.release + */ + def dynamicRevision = "latest.integration" + + /** Repositories. Comment in or out to taste. + */ + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" + val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" + + protected implicit lazy val implicitTransform: ArtifactTransform = + ArtifactTransform(inScope("test"), withSources) + + /*** Libraries ***/ + val specs: ModuleID = "org.scala-tools.testing" %% "specs" + val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" + + // val ant: ModuleID = "org.apache.ant" % "ant" + // val asmAll: ModuleID = "asm" % "asm-all" withSources() + // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" + // val easymock: ModuleID = "org.easymock" % "easymock" + // val guava: ModuleID = "com.google.guava" % "guava" + // val ivy: ModuleID = "org.apache.ivy" % "ivy" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" + // val jmock: ModuleID = "org.jmock" % "jmock" + // val jodaTime: ModuleID = "joda-time" % "joda-time" + // val liftJson: ModuleID = "net.liftweb" %% "lift-json" + // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" + // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() + // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() + // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() + // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() +} + +trait ModuleIdDynamifactory extends Dynamifactory { + self: DefaultProject => + + protected type DepId = GroupArtifactID + protected type DepOut = ModuleID + protected def finishDependency(in: GroupArtifactID, revision: String): ModuleID = in % revision + + protected implicit lazy val implicitRevision: ArtifactRevision = + ArtifactRevision(_ => dynamicRevision) + + protected def inScope(scope: String): DepFn = _ % scope + protected def withSources: DepFn = _.withSources() + protected def intransitive: DepFn = _.intransitive() + protected def withJavadoc: DepFn = _.withJavadoc + + protected def withRevision(newRevision: String): DepFn = (m: ModuleID) => { + ModuleID(m.organization, m.name, newRevision, m.configurations, m.isChanging, m.isTransitive, m.explicitArtifacts, m.extraAttributes) + } +} + +trait Dynamifactory { + protected type DepId + protected type DepOut + protected type DepFn = DepOut => DepOut + protected def dynamicRevision: String + protected def finishDependency(in: DepId, revision: String): DepOut + + case class ArtifactRevision(revisionFn: DepId => String) { + } + case class ArtifactTransform(fns: DepFn*) { + def apply(x: DepOut): DepOut = if (fns.isEmpty) x else fns.reduceLeft(_ andThen _)(x) + } + case class ArtifactConfig(rev: ArtifactRevision, transform: ArtifactTransform) { } + + protected implicit def autoassembleConfig(implicit rev: ArtifactRevision, transform: ArtifactTransform): ArtifactConfig = + ArtifactConfig(rev, transform) + + protected implicit def autoconfigureDependencies(in: DepId)(implicit config: ArtifactConfig): DepOut = { + val ArtifactConfig(ArtifactRevision(revisionFn), transform) = config + + transform(finishDependency(in, revisionFn(in))) + } } diff --git a/project/plugins/Plugins.scala b/project/plugins/Plugins.scala new file mode 100644 index 000000000..ea05fabe5 --- /dev/null +++ b/project/plugins/Plugins.scala @@ -0,0 +1,7 @@ +import sbt._ + +class Plugins(info: ProjectInfo) extends PluginDefinition(info) { + // def aquteRepo = "aQute Maven Repository" at "http://www.aqute.biz/repo" + // lazy val aquteModuleConfig = ModuleConfiguration("biz.aQute", aquteRepo) + // val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "latest.release" +}