mirror of https://github.com/sbt/sbt.git
Merge branch '1.1.x' into merge-1.1.x-into-1.x
* 1.1.x: Use Java's redirectInput rather than sys.process's connectInput Re-write toolboxClasspath to use sbt-buildinfo Cleanup generateToolboxClasspath Upgrade to sbt-buildinfo 0.8.0 Fix how fullClasspath is defined in TestBuildInfo delete buildinfo.BuildInfo from sbt main Conflicts: project/plugins.sbt
This commit is contained in:
commit
90cd60f3b9
|
|
@ -1,6 +1,5 @@
|
|||
target/
|
||||
__pycache__
|
||||
toolbox.classpath
|
||||
out
|
||||
node_modules
|
||||
vscode-sbt-scala/client/server
|
||||
|
|
|
|||
36
build.sbt
36
build.sbt
|
|
@ -402,33 +402,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 classpathAttributes = (dependencyClasspath in Compile).value
|
||||
val dependenciesClasspath =
|
||||
classpathAttributes.map(_.data.getAbsolutePath).mkString(":")
|
||||
val scalaBinVersion = (scalaBinaryVersion in Compile).value
|
||||
val targetDir = (target in Compile).value
|
||||
val compiledClassesDir = targetDir / s"scala-$scalaBinVersion/classes"
|
||||
val testClassesDir = targetDir / s"scala-$scalaBinVersion/test-classes"
|
||||
val classpath = s"$compiledClassesDir:$testClassesDir:$dependenciesClasspath"
|
||||
val resourceDir = (resourceDirectory in Compile).value
|
||||
resourceDir.mkdir() // In case it doesn't exist
|
||||
val toolboxTestClasspath = resourceDir / "toolbox.classpath"
|
||||
IO.write(toolboxTestClasspath, classpath)
|
||||
val result = List(toolboxTestClasspath.getAbsoluteFile)
|
||||
streams.value.log.success("Wrote the classpath for the macro neg test suite.")
|
||||
result
|
||||
}
|
||||
|
||||
// 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 Compile += 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"),
|
||||
|
|
@ -493,10 +481,14 @@ lazy val sbtProj = (project in file("sbt"))
|
|||
javaOptions ++= Seq("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"),
|
||||
mimaSettings,
|
||||
mimaBinaryIssueFilters ++= sbtIgnoredProblems,
|
||||
BuildInfoPlugin.buildInfoDefaultSettings,
|
||||
addBuildInfoToConfig(Test),
|
||||
BuildInfoPlugin.buildInfoDefaultSettings,
|
||||
buildInfoObject in Test := "TestBuildInfo",
|
||||
buildInfoKeys in Test := Seq[BuildInfoKey](fullClasspath in Compile),
|
||||
buildInfoKeys in Test := Seq[BuildInfoKey](
|
||||
// WORKAROUND https://github.com/sbt/sbt-buildinfo/issues/117
|
||||
BuildInfoKey.map((fullClasspath in Compile).taskValue) { case (ident, cp) => ident -> cp.files },
|
||||
),
|
||||
connectInput in run in Test := true,
|
||||
outputStrategy in run in Test := Some(StdoutOutput),
|
||||
fork in Test := true,
|
||||
|
|
|
|||
|
|
@ -22,9 +22,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 ":"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ scalacOptions ++= Seq("-feature", "-language:postfixOps")
|
|||
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.5")
|
||||
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.2")
|
||||
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2")
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.8.0")
|
||||
addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.9")
|
||||
|
|
|
|||
|
|
@ -8,10 +8,14 @@
|
|||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import java.lang.ProcessBuilder.Redirect
|
||||
|
||||
import scala.sys.process.Process
|
||||
import OutputStrategy._
|
||||
import sbt.internal.util.Util
|
||||
|
||||
import java.lang.{ ProcessBuilder => JProcessBuilder }
|
||||
|
||||
/**
|
||||
* Represents a command that can be forked.
|
||||
*
|
||||
|
|
@ -45,13 +49,19 @@ final class Fork(val commandName: String, val runnerClass: Option[String]) {
|
|||
(classpathEnv map { value =>
|
||||
Fork.ClasspathEnvKey -> value
|
||||
})
|
||||
val process = Process(command, workingDirectory, environment.toList: _*)
|
||||
val jpb = new JProcessBuilder(command.toArray: _*)
|
||||
workingDirectory foreach (jpb directory _)
|
||||
environment foreach { case (k, v) => jpb.environment.put(k, v) }
|
||||
if (connectInput)
|
||||
jpb.redirectInput(Redirect.INHERIT)
|
||||
val process = Process(jpb)
|
||||
|
||||
outputStrategy.getOrElse(StdoutOutput) match {
|
||||
case StdoutOutput => process.run(connectInput)
|
||||
case out: BufferedOutput => out.logger.buffer { process.run(out.logger, connectInput) }
|
||||
case out: LoggedOutput => process.run(out.logger, connectInput)
|
||||
case out: CustomOutput => (process #> out.output).run(connectInput)
|
||||
case StdoutOutput => process.run(connectInput = false)
|
||||
case out: BufferedOutput =>
|
||||
out.logger.buffer { process.run(out.logger, connectInput = false) }
|
||||
case out: LoggedOutput => process.run(out.logger, connectInput = false)
|
||||
case out: CustomOutput => (process #> out.output).run(connectInput = false)
|
||||
}
|
||||
}
|
||||
private[this] def makeOptions(jvmOptions: Seq[String],
|
||||
|
|
|
|||
|
|
@ -92,11 +92,7 @@ object RunFromSourceMain {
|
|||
)
|
||||
def appHome: File = scalaHome / id.groupID / id.name / id.version
|
||||
|
||||
def mainClasspath =
|
||||
buildinfo.TestBuildInfo.fullClasspath.iterator
|
||||
.map(s => file(s.stripPrefix("Attributed(").stripSuffix(")")))
|
||||
.toArray
|
||||
|
||||
def mainClasspath = buildinfo.TestBuildInfo.fullClasspath.toArray
|
||||
def loader = new java.net.URLClassLoader(mainClasspath map (_.toURI.toURL), null)
|
||||
def entryPoint = classOf[xMain]
|
||||
def mainClass = classOf[xMain]
|
||||
|
|
|
|||
Loading…
Reference in New Issue