diff --git a/build.sbt b/build.sbt index 60d2cce1e..86916cc53 100644 --- a/build.sbt +++ b/build.sbt @@ -105,8 +105,9 @@ lazy val testingProj = (project in file("testing")). settings( baseSettings, name := "Testing", - libraryDependencies ++= Seq(sbtIO, testInterface,launcherInterface, compilerClasspath, utilLogging) - ) + libraryDependencies ++= Seq(testInterface,launcherInterface) + ). + configure(addSbtIO, addSbtCompilerClasspath, addSbtUtilLogging) // Testing agent for running tests in a separate process. lazy val testAgentProj = (project in file("testing") / "agent"). @@ -123,9 +124,9 @@ lazy val testAgentProj = (project in file("testing") / "agent"). lazy val taskProj = (project in file("tasks")). settings( testedBaseSettings, - name := "Tasks", - libraryDependencies ++= Seq(utilControl, utilCollection) - ) + name := "Tasks" + ). + configure(addSbtUtilControl, addSbtUtilCollection) // Standard task system. This provides map, flatMap, join, and more on top of the basic task model. lazy val stdTaskProj = (project in file("tasks-standard")). @@ -133,46 +134,45 @@ lazy val stdTaskProj = (project in file("tasks-standard")). settings( testedBaseSettings, name := "Task System", - testExclusive, - libraryDependencies ++= Seq(utilCollection, utilLogging, sbtIO) - ) + testExclusive + ). + configure(addSbtUtilCollection, addSbtUtilLogging, addSbtIO) // Embedded Scala code runner lazy val runProj = (project in file("run")). settings( testedBaseSettings, - name := "Run", - libraryDependencies ++= Seq(sbtIO, - utilLogging, compilerClasspath) - ) + name := "Run" + ). + configure(addSbtIO, addSbtUtilLogging, addSbtCompilerClasspath) lazy val scriptedSbtProj = (project in scriptedPath / "sbt"). dependsOn(commandProj). settings( baseSettings, name := "Scripted sbt", - libraryDependencies ++= Seq(launcherInterface % "provided", - sbtIO, utilLogging, compilerInterface, utilScripted) - ) + libraryDependencies ++= Seq(launcherInterface % "provided") + ). + configure(addSbtIO, addSbtUtilLogging, addSbtCompilerInterface, addSbtUtilScripted) lazy val scriptedPluginProj = (project in scriptedPath / "plugin"). dependsOn(sbtProj). settings( baseSettings, - name := "Scripted Plugin", - libraryDependencies ++= Seq(compilerClasspath) - ) + name := "Scripted Plugin" + ). + configure(addSbtCompilerClasspath) // Implementation and support code for defining actions. lazy val actionsProj = (project in file("main-actions")). dependsOn(runProj, stdTaskProj, taskProj, testingProj). settings( testedBaseSettings, - name := "Actions", - libraryDependencies ++= Seq(compilerClasspath, utilCompletion, compilerApiInfo, - zinc, compilerIvyIntegration, compilerInterface, - sbtIO, utilLogging, utilRelation, libraryManagement, utilTracking) - ) + name := "Actions" + ). + configure(addSbtCompilerClasspath, addSbtUtilCompletion, addSbtCompilerApiInfo, + addSbtZinc, addSbtCompilerIvyIntegration, addSbtCompilerInterface, + addSbtIO, addSbtUtilLogging, addSbtUtilRelation, addSbtLm, addSbtUtilTracking) // General command support and core commands not specific to a build system lazy val commandProj = (project in file("main-command")). @@ -180,20 +180,20 @@ lazy val commandProj = (project in file("main-command")). settings( testedBaseSettings, name := "Command", - libraryDependencies ++= Seq(launcherInterface, compilerInterface, - sbtIO, utilLogging, utilCompletion, compilerClasspath, sjsonNewScalaJson), + libraryDependencies ++= Seq(launcherInterface, sjsonNewScalaJson), sourceManaged in (Compile, generateDatatypes) := baseDirectory.value / "src" / "main" / "datatype-scala" - ) + ). + configure(addSbtCompilerInterface, addSbtIO, addSbtUtilLogging, addSbtUtilCompletion, addSbtCompilerClasspath) // Fixes scope=Scope for Setting (core defined in collectionProj) to define the settings system used in build definitions lazy val mainSettingsProj = (project in file("main-settings")). dependsOn(commandProj, stdTaskProj). settings( testedBaseSettings, - name := "Main Settings", - libraryDependencies ++= Seq(utilCache, utilApplyMacro, compilerInterface, utilRelation, - utilLogging, sbtIO, utilCompletion, compilerClasspath, libraryManagement) - ) + name := "Main Settings" + ). + configure(addSbtUtilCache, addSbtUtilApplyMacro, addSbtCompilerInterface, addSbtUtilRelation, + addSbtUtilLogging, addSbtIO, addSbtUtilCompletion, addSbtCompilerClasspath, addSbtLm) // The main integration project for sbt. It brings all of the projects together, configures them, and provides for overriding conventions. lazy val mainProj = (project in file("main")). @@ -201,9 +201,10 @@ lazy val mainProj = (project in file("main")). settings( testedBaseSettings, name := "Main", - libraryDependencies ++= scalaXml.value ++ Seq(launcherInterface, compilerInterface, - sbtIO, utilLogging, utilLogic, libraryManagement, zincCompile) - ) + libraryDependencies ++= scalaXml.value ++ Seq(launcherInterface) + ). + configure(addSbtCompilerInterface, + addSbtIO, addSbtUtilLogging, addSbtUtilLogic, addSbtLm, addSbtZincCompile) // Strictly for bringing implicits and aliases from subsystems into the top-level sbt namespace through a single package object // technically, we need a dependency on all of mainProj's dependencies, but we don't do that since this is strictly an integration project @@ -215,9 +216,9 @@ lazy val sbtProj = (project in file("sbt")). name := "sbt", normalizedName := "sbt", crossScalaVersions := Seq(scala211), - crossPaths := false, - libraryDependencies ++= Seq(compilerBridge) - ) + crossPaths := false + ). + configure(addSbtCompilerBridge) def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask { val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 9eda402e1..c330e97e1 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -9,38 +9,81 @@ object Dependencies { val scala211 = "2.11.8" // sbt modules - val ioVersion = "1.0.0-M6" - val utilVersion = "0.1.0-M14" - val lmVersion = "0.1.0-X1" - val zincVersion = "1.0.0-X3" + private val ioVersion = "1.0.0-M6" + private val utilVersion = "0.1.0-M14" + private val lmVersion = "0.1.0-X1" + private val zincVersion = "1.0.0-X3" - val sbtIO = "org.scala-sbt" %% "io" % ioVersion + private val sbtIO = "org.scala-sbt" %% "io" % ioVersion - val utilApplyMacro = "org.scala-sbt" %% "util-apply-macro" % utilVersion - val utilCache = "org.scala-sbt" %% "util-cache" % utilVersion - val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion - val utilCompletion = "org.scala-sbt" %% "util-completion" % utilVersion - val utilControl = "org.scala-sbt" %% "util-control" % utilVersion - val utilLogging = "org.scala-sbt" %% "util-logging" % utilVersion - val utilLogic = "org.scala-sbt" %% "util-logic" % utilVersion - val utilRelation = "org.scala-sbt" %% "util-relation" % utilVersion - val utilScripted = "org.scala-sbt" %% "util-scripted" % utilVersion - val utilTesting = "org.scala-sbt" %% "util-testing" % utilVersion - val utilTracking = "org.scala-sbt" %% "util-tracking" % utilVersion + private val utilApplyMacro = "org.scala-sbt" %% "util-apply-macro" % utilVersion + private val utilCache = "org.scala-sbt" %% "util-cache" % utilVersion + private val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion + private val utilCompletion = "org.scala-sbt" %% "util-completion" % utilVersion + private val utilControl = "org.scala-sbt" %% "util-control" % utilVersion + private val utilLogging = "org.scala-sbt" %% "util-logging" % utilVersion + private val utilLogic = "org.scala-sbt" %% "util-logic" % utilVersion + private val utilRelation = "org.scala-sbt" %% "util-relation" % utilVersion + private val utilScripted = "org.scala-sbt" %% "util-scripted" % utilVersion + private val utilTesting = "org.scala-sbt" %% "util-testing" % utilVersion + private val utilTracking = "org.scala-sbt" %% "util-tracking" % utilVersion - val libraryManagement = "org.scala-sbt" %% "librarymanagement" % lmVersion + private val libraryManagement = "org.scala-sbt" %% "librarymanagement" % lmVersion val launcherInterface = "org.scala-sbt" % "launcher-interface" % "1.0.0" val rawLauncher = "org.scala-sbt" % "launcher" % "1.0.0" val testInterface = "org.scala-sbt" % "test-interface" % "1.0" - val compilerApiInfo = "org.scala-sbt" %% "zinc-apiinfo" % zincVersion - val compilerBridge = "org.scala-sbt" %% "compiler-bridge" % zincVersion - val compilerClasspath = "org.scala-sbt" %% "zinc-classpath" % zincVersion - val compilerInterface = "org.scala-sbt" % "compiler-interface" % zincVersion - val compilerIvyIntegration = "org.scala-sbt" %% "zinc-ivy-integration" % zincVersion - val zinc = "org.scala-sbt" %% "zinc" % zincVersion - val zincCompile = "org.scala-sbt" %% "zinc-compile" % zincVersion + private val compilerApiInfo = "org.scala-sbt" %% "zinc-apiinfo" % zincVersion + private val compilerBridge = "org.scala-sbt" %% "compiler-bridge" % zincVersion + private val compilerClasspath = "org.scala-sbt" %% "zinc-classpath" % zincVersion + private val compilerInterface = "org.scala-sbt" % "compiler-interface" % zincVersion + private val compilerIvyIntegration = "org.scala-sbt" %% "zinc-ivy-integration" % zincVersion + private val zinc = "org.scala-sbt" %% "zinc" % zincVersion + private val zincCompile = "org.scala-sbt" %% "zinc-compile" % zincVersion + + def getSbtModulePath(key: String, name: String) = { + val localProps = new java.util.Properties() + IO.load(localProps, file("project/local.properties")) + val path = Option(localProps getProperty key) orElse (sys.props get key) + path foreach (f => println(s"Using $name from $f")) + path + } + + lazy val sbtIoPath = getSbtModulePath("sbtio.path", "sbt/io") + lazy val sbtUtilPath = getSbtModulePath("sbtutil.path", "sbt/util") + lazy val sbtLmPath = getSbtModulePath("sbtlm.path", "sbt/lm") + lazy val sbtZincPath = getSbtModulePath("sbtzinc.path", "sbt/zinc") + + def addSbtModule(p: Project, path: Option[String], projectName: String, m: ModuleID, c: Option[Configuration] = None) = + path match { + case Some(f) => p dependsOn c.fold[ClasspathDependency](ProjectRef(file(f), projectName))(ProjectRef(file(f), projectName) % _) + case None => p settings (libraryDependencies += c.fold(m)(m % _)) + } + + def addSbtIO(p: Project): Project = addSbtModule(p, sbtIoPath, "io", sbtIO) + + def addSbtUtilApplyMacro(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilApplyMacro", utilApplyMacro) + def addSbtUtilCache(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilCache", utilCache) + def addSbtUtilCollection(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilCollection", utilCollection) + def addSbtUtilCompletion(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilComplete", utilCompletion) + def addSbtUtilControl(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilControl", utilControl) + def addSbtUtilLogging(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilLogging", utilLogging) + def addSbtUtilLogic(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilLogic", utilLogic) + def addSbtUtilRelation(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilRelation", utilRelation) + def addSbtUtilScripted(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilScripted", utilScripted) + def addSbtUtilTesting(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilTesting", utilTesting, Some(Test)) + def addSbtUtilTracking(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilTracking", utilTracking) + + def addSbtLm(p: Project): Project = addSbtModule(p, sbtLmPath, "lm", libraryManagement) + + def addSbtCompilerApiInfo(p: Project): Project = addSbtModule(p, sbtZincPath, "zincApiInfo", compilerApiInfo) + def addSbtCompilerBridge(p: Project): Project = addSbtModule(p, sbtZincPath, "compilerBridge", compilerBridge) + def addSbtCompilerClasspath(p: Project): Project = addSbtModule(p, sbtZincPath, "zincClasspath", compilerClasspath) + def addSbtCompilerInterface(p: Project): Project = addSbtModule(p, sbtZincPath, "compilerInterface", compilerInterface) + def addSbtCompilerIvyIntegration(p: Project): Project = addSbtModule(p, sbtZincPath, "zincIvyIntegration", compilerIvyIntegration) + def addSbtZinc(p: Project): Project = addSbtModule(p, sbtZincPath, "zinc", zinc) + def addSbtZincCompile(p: Project): Project = addSbtModule(p, sbtZincPath, "zincCompile", zincCompile) val sjsonNewScalaJson = "com.eed3si9n" %% "sjson-new-scalajson" % "0.4.2"