Re-write toolboxClasspath to use sbt-buildinfo

This commit is contained in:
Dale Wijnand 2018-01-26 16:02:30 +00:00
parent 8182741480
commit 27fe5a6957
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
3 changed files with 13 additions and 25 deletions

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
target/
__pycache__
toolbox.classpath
out
node_modules
vscode-sbt-scala/client/server

View File

@ -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"),

View File

@ -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 ":"
}
}