From 9494967e055a64389f4b002e3485ac0f0367579d Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 26 Jun 2017 11:38:37 +0100 Subject: [PATCH] Upgrade util/lm/zinc & config build for util modules Welcome back home! --- build.sbt | 75 +++++++++++++------ .../src/test/scala/UnitSpec.scala | 5 ++ .../src/test/scala/UnitSpec.scala | 5 ++ main-actions/src/main/scala/sbt/Package.scala | 1 + .../src/main/scala/sbt/RawCompileLike.scala | 1 + .../internal/AltLibraryManagementCodec.scala | 1 + .../sbt/internal/LibraryManagement.scala | 1 + project/Dependencies.scala | 65 +++++++--------- project/Util.scala | 18 +++-- .../cache-update/build.sbt | 1 + 10 files changed, 103 insertions(+), 70 deletions(-) create mode 100644 internal/util-collection/src/test/scala/UnitSpec.scala create mode 100644 internal/util-complete/src/test/scala/UnitSpec.scala diff --git a/build.sbt b/build.sbt index 8bd3aa316..df186e3cd 100644 --- a/build.sbt +++ b/build.sbt @@ -124,6 +124,34 @@ lazy val bundledLauncherProj = /* ** subproject declarations ** */ +val collectionProj = (project in file("internal") / "util-collection") + .settings( + testedBaseSettings, + Util.keywordsSettings, + name := "Collections", + libraryDependencies ++= Seq(sjsonNewScalaJson.value) + ) + .configure(addSbtUtilPosition) + +// Command line-related utilities. +val completeProj = (project in file("internal") / "util-complete") + .dependsOn(collectionProj) + .settings( + testedBaseSettings, + name := "Completion", + libraryDependencies += jline + ) + .configure(addSbtIO, addSbtUtilControl) + +// A logic with restricted negation as failure for a unique, stable model +val logicProj = (project in file("internal") / "util-logic") + .dependsOn(collectionProj) + .settings( + testedBaseSettings, + name := "Logic" + ) + .configure(addSbtUtilRelation) + /* **** Intermediate-level Modules **** */ // Runner for uniform test interface @@ -154,21 +182,23 @@ lazy val testAgentProj = (project in file("testing") / "agent") // Basic task engine lazy val taskProj = (project in file("tasks")) + .dependsOn(collectionProj) .settings( testedBaseSettings, name := "Tasks" ) - .configure(addSbtUtilControl, addSbtUtilCollection) + .configure(addSbtUtilControl) // 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")) + .dependsOn(collectionProj) .dependsOn(taskProj % "compile;test->test") .settings( testedBaseSettings, name := "Task System", testExclusive ) - .configure(addSbtUtilCollection, addSbtUtilLogging, addSbtUtilCache, addSbtIO) + .configure(addSbtIO, addSbtUtilLogging, addSbtUtilCache) // Embedded Scala code runner lazy val runProj = (project in file("run")) @@ -201,24 +231,23 @@ lazy val scriptedPluginProj = (project in scriptedPath / "plugin") // Implementation and support code for defining actions. lazy val actionsProj = (project in file("main-actions")) - .dependsOn(runProj, stdTaskProj, taskProj, testingProj) + .dependsOn(completeProj, runProj, stdTaskProj, taskProj, testingProj) .settings( testedBaseSettings, name := "Actions", libraryDependencies += sjsonNewScalaJson.value ) .configure( - addSbtCompilerClasspath, - addSbtUtilCompletion, - addSbtCompilerApiInfo, - addSbtZinc, - addSbtCompilerIvyIntegration, - addSbtCompilerInterface, addSbtIO, addSbtUtilLogging, addSbtUtilRelation, + addSbtCompilerInterface, + addSbtCompilerClasspath, + addSbtCompilerApiInfo, + addSbtUtilTracking, addSbtLm, - addSbtUtilTracking + addSbtCompilerIvyIntegration, + addSbtZinc ) lazy val protocolProj = (project in file("protocol")) @@ -237,7 +266,7 @@ lazy val protocolProj = (project in file("protocol")) // General command support and core commands not specific to a build system lazy val commandProj = (project in file("main-command")) .enablePlugins(ContrabandPlugin, JsonCodecPlugin) - .dependsOn(protocolProj) + .dependsOn(protocolProj, completeProj) .settings( testedBaseSettings, name := "Command", @@ -248,10 +277,9 @@ lazy val commandProj = (project in file("main-command")) contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats ) .configure( - addSbtCompilerInterface, addSbtIO, addSbtUtilLogging, - addSbtUtilCompletion, + addSbtCompilerInterface, addSbtCompilerClasspath, addSbtLm ) @@ -259,12 +287,12 @@ lazy val commandProj = (project in file("main-command")) // The core macro project defines the main logic of the DSL, abstracted // away from several sbt implementators (tasks, settings, et cetera). lazy val coreMacrosProj = (project in file("core-macros")) + .dependsOn(collectionProj) .settings( commonSettings, name := "Core Macros", libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value ) - .configure(addSbtUtilCollection) /* Write all the compile-time dependencies of the spores macro to a file, * in order to read it from the created Toolbox to run the neg tests. */ @@ -288,19 +316,18 @@ lazy val generateToolboxClasspath = Def.task { // 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, coreMacrosProj) + .dependsOn(completeProj, commandProj, stdTaskProj, coreMacrosProj) .settings( testedBaseSettings, name := "Main Settings", resourceGenerators in Compile += generateToolboxClasspath.taskValue ) .configure( - addSbtUtilCache, - addSbtCompilerInterface, - addSbtUtilRelation, - addSbtUtilLogging, addSbtIO, - addSbtUtilCompletion, + addSbtUtilLogging, + addSbtUtilCache, + addSbtUtilRelation, + addSbtCompilerInterface, addSbtCompilerClasspath, addSbtLm ) @@ -308,7 +335,7 @@ lazy val mainSettingsProj = (project in file("main-settings")) // 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")) .enablePlugins(ContrabandPlugin) - .dependsOn(actionsProj, mainSettingsProj, runProj, commandProj) + .dependsOn(logicProj, actionsProj, mainSettingsProj, runProj, commandProj) .settings( testedBaseSettings, name := "Main", @@ -318,10 +345,9 @@ lazy val mainProj = (project in file("main")) sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala" ) .configure( - addSbtCompilerInterface, addSbtIO, addSbtUtilLogging, - addSbtUtilLogic, + addSbtCompilerInterface, addSbtLm, addSbtZincCompile ) @@ -379,6 +405,9 @@ lazy val publishLauncher = TaskKey[Unit]("publish-launcher") def allProjects = Seq( + collectionProj, + logicProj, + completeProj, testingProj, testAgentProj, taskProj, diff --git a/internal/util-collection/src/test/scala/UnitSpec.scala b/internal/util-collection/src/test/scala/UnitSpec.scala new file mode 100644 index 000000000..99ad43c2d --- /dev/null +++ b/internal/util-collection/src/test/scala/UnitSpec.scala @@ -0,0 +1,5 @@ +package sbt.internal.util + +import org.scalatest._ + +abstract class UnitSpec extends FlatSpec with Matchers diff --git a/internal/util-complete/src/test/scala/UnitSpec.scala b/internal/util-complete/src/test/scala/UnitSpec.scala new file mode 100644 index 000000000..99ad43c2d --- /dev/null +++ b/internal/util-complete/src/test/scala/UnitSpec.scala @@ -0,0 +1,5 @@ +package sbt.internal.util + +import org.scalatest._ + +abstract class UnitSpec extends FlatSpec with Matchers diff --git a/main-actions/src/main/scala/sbt/Package.scala b/main-actions/src/main/scala/sbt/Package.scala index 628730c9d..fbf211416 100644 --- a/main-actions/src/main/scala/sbt/Package.scala +++ b/main-actions/src/main/scala/sbt/Package.scala @@ -16,6 +16,7 @@ import sbt.util.Logger import sbt.util.{ CacheStoreFactory, FilesInfo, ModifiedFileInfo, PlainFileInfo } import sbt.internal.util.HNil +import sbt.internal.util.HListFormats._ import sbt.util.FileInfo.{ exists, lastModified } import sbt.util.CacheImplicits._ import sbt.util.Tracked.inputChanged diff --git a/main-actions/src/main/scala/sbt/RawCompileLike.scala b/main-actions/src/main/scala/sbt/RawCompileLike.scala index bd2a20618..543590277 100644 --- a/main-actions/src/main/scala/sbt/RawCompileLike.scala +++ b/main-actions/src/main/scala/sbt/RawCompileLike.scala @@ -11,6 +11,7 @@ import sbt.io.syntax._ import sbt.io.IO import sbt.internal.util.Types.:+: +import sbt.internal.util.HListFormats._ import sbt.util.CacheImplicits._ import sbt.util.Tracked.inputChanged import sbt.util.{ CacheStoreFactory, FilesInfo, HashFileInfo, ModifiedFileInfo, PlainFileInfo } diff --git a/main/src/main/scala/sbt/internal/AltLibraryManagementCodec.scala b/main/src/main/scala/sbt/internal/AltLibraryManagementCodec.scala index 8ceed18fb..5fb7ca469 100644 --- a/main/src/main/scala/sbt/internal/AltLibraryManagementCodec.scala +++ b/main/src/main/scala/sbt/internal/AltLibraryManagementCodec.scala @@ -3,6 +3,7 @@ package sbt.internal import sbt.internal.librarymanagement._ import sbt.internal.util.Types._ import sbt.internal.util.{ HList, HNil } +import sbt.internal.util.HListFormats._ import sbt.io.{ Hash, IO } import sbt.librarymanagement._ import sbt.util.CacheImplicits._ diff --git a/main/src/main/scala/sbt/internal/LibraryManagement.scala b/main/src/main/scala/sbt/internal/LibraryManagement.scala index ac2894d3a..17474b990 100644 --- a/main/src/main/scala/sbt/internal/LibraryManagement.scala +++ b/main/src/main/scala/sbt/internal/LibraryManagement.scala @@ -5,6 +5,7 @@ import java.io.File import sbt.internal.librarymanagement._ import sbt.internal.util.HNil import sbt.internal.util.Types._ +import sbt.internal.util.HListFormats._ import sbt.librarymanagement._ import sbt.librarymanagement.syntax._ import sbt.util.CacheImplicits._ diff --git a/project/Dependencies.scala b/project/Dependencies.scala index bac99155a..b65ce1108 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -13,22 +13,19 @@ object Dependencies { // sbt modules private val ioVersion = "1.0.0-M12" - private val utilVersion = "1.0.0-M25" - private val lmVersion = "1.0.0-X16" - private val zincVersion = "1.0.0-X17" + private val utilVersion = "1.0.0-M26" + private val lmVersion = "1.0.0-X17" + private val zincVersion = "1.0.0-X18" private val sbtIO = "org.scala-sbt" %% "io" % ioVersion - 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 utilPosition = "org.scala-sbt" %% "util-position" % utilVersion private val utilLogging = "org.scala-sbt" %% "util-logging" % utilVersion - private val utilLogic = "org.scala-sbt" %% "util-logic" % utilVersion + private val utilCache = "org.scala-sbt" %% "util-cache" % utilVersion + private val utilControl = "org.scala-sbt" %% "util-control" % 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 + private val utilScripted = "org.scala-sbt" %% "util-scripted" % utilVersion private val libraryManagement = "org.scala-sbt" %% "librarymanagement" % lmVersion @@ -36,10 +33,10 @@ object Dependencies { val rawLauncher = "org.scala-sbt" % "launcher" % "1.0.0" val testInterface = "org.scala-sbt" % "test-interface" % "1.0" + private val compilerInterface = "org.scala-sbt" % "compiler-interface" % zincVersion + private val compilerClasspath = "org.scala-sbt" %% "zinc-classpath" % 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 @@ -57,51 +54,39 @@ object Dependencies { 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 - ) = + def addSbtModule(p: Project, path: Option[String], projectName: String, m: ModuleID) = path match { - case Some(f) => - p dependsOn c.fold[ClasspathDep[ProjectReference]](ProjectRef(file(f), projectName))( - ProjectRef(file(f), projectName) % _) - case None => p settings (libraryDependencies += c.fold(m)(m % _)) + case Some(f) => p dependsOn ProjectRef(file(f), projectName) + case None => p settings (libraryDependencies += m) } def addSbtIO(p: Project): Project = addSbtModule(p, sbtIoPath, "io", sbtIO) - 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 addSbtUtilPosition(p: Project): Project = + addSbtModule(p, sbtUtilPath, "utilPosition", utilPosition) def addSbtUtilLogging(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilLogging", utilLogging) - def addSbtUtilLogic(p: Project): Project = addSbtModule(p, sbtUtilPath, "utilLogic", utilLogic) + def addSbtUtilCache(p: Project): Project = + addSbtModule(p, sbtUtilPath, "utilCache", utilCache) + def addSbtUtilControl(p: Project): Project = + addSbtModule(p, sbtUtilPath, "utilControl", utilControl) 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 addSbtUtilScripted(p: Project): Project = + addSbtModule(p, sbtUtilPath, "utilScripted", utilScripted) def addSbtLm(p: Project): Project = addSbtModule(p, sbtLmPath, "lm", libraryManagement) + def addSbtCompilerInterface(p: Project): Project = + addSbtModule(p, sbtZincPath, "compilerInterface", compilerInterface) + def addSbtCompilerClasspath(p: Project): Project = + addSbtModule(p, sbtZincPath, "zincClasspath", compilerClasspath) 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) @@ -109,6 +94,8 @@ object Dependencies { addSbtModule(p, sbtZincPath, "zincCompile", zincCompile) val sjsonNewScalaJson = Def.setting { "com.eed3si9n" %% "sjson-new-scalajson" % contrabandSjsonNewVersion.value } + + val jline = "jline" % "jline" % "2.14.4" val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4" val specs2 = "org.specs2" %% "specs2" % "2.4.17" diff --git a/project/Util.scala b/project/Util.scala index bfb02bd2b..8a4b408bc 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -162,13 +162,14 @@ object Util { def writeScalaKeywords(base: File, keywords: Set[String]): File = { val init = keywords.map(tn => '"' + tn + '"').mkString("Set(", ", ", ")") val ObjectName = "ScalaKeywords" - val PackageName = "sbt" - val keywordsSrc = - """package %s -object %s { - val values = %s -}""".format(PackageName, ObjectName, init) - val out = base / PackageName.replace('.', '/') / (ObjectName + ".scala") + val PackageName = "sbt.internal.util" + val keywordsSrc = s""" + |package $PackageName + |object $ObjectName { + | val values = $init + |} + """.trim.stripMargin + val out = base / PackageName.replace('.', '/') / s"$ObjectName.scala" IO.write(out, keywordsSrc) out } @@ -179,7 +180,8 @@ object %s { scalaKeywords := getScalaKeywords, generateKeywords := writeScalaKeywords(sourceManaged.value, scalaKeywords.value), sourceGenerators += Def.task(Seq(generateKeywords.value)).taskValue - )) + ) + ) } object Licensed { diff --git a/sbt/src/sbt-test/dependency-management/cache-update/build.sbt b/sbt/src/sbt-test/dependency-management/cache-update/build.sbt index 38eb67043..5afcc2440 100644 --- a/sbt/src/sbt-test/dependency-management/cache-update/build.sbt +++ b/sbt/src/sbt-test/dependency-management/cache-update/build.sbt @@ -24,6 +24,7 @@ lazy val root = (project in file(".")) type In = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil import sbt.util.CacheImplicits._ + import sbt.internal.util.HListFormats._ import sbt.internal.AltLibraryManagementCodec._ val f: In => Unit =