From 27fe5a6957b751bc0d5d6d311f2f8b1fd382e4e0 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 26 Jan 2018 16:02:30 +0000 Subject: [PATCH] Re-write toolboxClasspath to use sbt-buildinfo --- .gitignore | 1 - build.sbt | 29 ++++++------------- .../src/test/scala/sbt/std/TestUtil.scala | 8 ++--- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 3996caad8..42de74605 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ target/ __pycache__ -toolbox.classpath out node_modules vscode-sbt-scala/client/server diff --git a/build.sbt b/build.sbt index 1c932281c..bb6df2c9d 100644 --- a/build.sbt +++ b/build.sbt @@ -361,32 +361,21 @@ lazy val coreMacrosProj = (project in file("core-macros")) mimaSettings, ) -/* 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. */ -lazy val generateToolboxClasspath = Def.task { - val mainClassesDir = (classDirectory in Compile).value - val testClassesDir = (classDirectory in Test).value - val depsClasspath = (dependencyClasspath in Compile).value - - val classpath = mainClassesDir +: testClassesDir +: (Attributed data depsClasspath) mkString ":" - - val resourceDir = (resourceDirectory in Compile).value - val toolboxTestClasspath = resourceDir / "toolbox.classpath" - - IO.write(toolboxTestClasspath, classpath) - - streams.value.log.success("Wrote the classpath for the macro neg test suite.") - - List(toolboxTestClasspath) -} - // 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(completeProj, commandProj, stdTaskProj, coreMacrosProj) .settings( testedBaseSettings, name := "Main Settings", - resourceGenerators in Test += generateToolboxClasspath.taskValue, + BuildInfoPlugin.buildInfoDefaultSettings, + addBuildInfoToConfig(Test), + buildInfoObject in Test := "TestBuildInfo", + buildInfoKeys in Test := Seq[BuildInfoKey]( + classDirectory in Compile, + classDirectory in Test, + // WORKAROUND https://github.com/sbt/sbt-buildinfo/issues/117 + BuildInfoKey.map((dependencyClasspath in Compile).taskValue) { case (ident, cp) => ident -> cp.files }, + ), mimaSettings, mimaBinaryIssueFilters ++= Seq( exclude[DirectMissingMethodProblem]("sbt.Scope.display012StyleMasked"), diff --git a/main-settings/src/test/scala/sbt/std/TestUtil.scala b/main-settings/src/test/scala/sbt/std/TestUtil.scala index ed6f15530..df02fb29c 100644 --- a/main-settings/src/test/scala/sbt/std/TestUtil.scala +++ b/main-settings/src/test/scala/sbt/std/TestUtil.scala @@ -24,9 +24,9 @@ object TestUtil { } lazy val toolboxClasspath: String = { - val resource = getClass.getClassLoader.getResource("toolbox.classpath") - val classpathFile = scala.io.Source.fromFile(resource.toURI) - val completeSporesCoreClasspath = classpathFile.getLines.mkString - completeSporesCoreClasspath + val mainClassesDir = buildinfo.TestBuildInfo.classDirectory + val testClassesDir = buildinfo.TestBuildInfo.test_classDirectory + val depsClasspath = buildinfo.TestBuildInfo.dependencyClasspath + mainClassesDir +: testClassesDir +: depsClasspath mkString ":" } }