Fix community build

The community build was broken for some projects because I broke builds
that relied on the unscoped definition of `runner`. To preserve legacy
behavior, I restore the old unscoped behavior and append the new scoped
runners that used the layered classloaders. This makes more sense
because the layered classloaders were specifically designed for the
Runtime and Test configurations and may not make sense in other
contexts.
This commit is contained in:
Ethan Atkins 2019-01-30 20:49:56 -08:00
parent f170d0c60c
commit 92807869ea
1 changed files with 32 additions and 5 deletions

View File

@ -609,7 +609,7 @@ object Defaults extends BuildCommon {
// note that we use the same runner and mainClass as plain run
mainBgRunMainTaskForConfig(This),
mainBgRunTaskForConfig(This)
) ++ inTask(run)(runnerSettings)
) ++ inTask(run)(runnerSettings ++ newRunnerSettings)
private[this] lazy val configGlobal = globalDefaults(
Seq(
@ -1406,11 +1406,37 @@ object Defaults extends BuildCommon {
}
}
@deprecated("This is no longer used internally by sbt.", "1.3.0")
def runnerTask: Setting[Task[ScalaRun]] = runner := runnerInit.value
@deprecated("This is no longer used internally by sbt.", "1.3.0")
def runnerInit: Initialize[Task[ScalaRun]] = ClassLoaders.runner
def runnerInit: Initialize[Task[ScalaRun]] = Def.task {
val tmp = taskTemporaryDirectory.value
val resolvedScope = resolvedScoped.value.scope
val si = scalaInstance.value
val s = streams.value
val opts = forkOptions.value
val options = javaOptions.value
val trap = trapExit.value
if (fork.value) {
s.log.debug(s"javaOptions: $options")
new ForkRun(opts)
} else {
if (options.nonEmpty) {
val mask = ScopeMask(project = false)
val showJavaOptions = Scope.displayMasked(
(javaOptions in resolvedScope).scopedKey.scope,
(javaOptions in resolvedScope).key.label,
mask
)
val showFork = Scope.displayMasked(
(fork in resolvedScope).scopedKey.scope,
(fork in resolvedScope).key.label,
mask
)
s.log.warn(s"$showJavaOptions will be ignored, $showFork is set to false")
}
new Run(si, trap, tmp)
}
}
private def foreachJobTask(
f: (BackgroundJobService, JobHandle) => Unit
@ -1760,7 +1786,8 @@ object Defaults extends BuildCommon {
// 1. runnerSettings is added unscoped via JvmPlugin.
// 2. In addition it's added scoped to run task.
lazy val runnerSettings: Seq[Setting[_]] = {
lazy val runnerSettings: Seq[Setting[_]] = Seq(runnerTask, forkOptions := forkOptionsTask.value)
private[this] lazy val newRunnerSettings: Seq[Setting[_]] = {
val unscoped: Seq[Def.Setting[_]] =
Seq(runner := ClassLoaders.runner.value, forkOptions := forkOptionsTask.value)
inConfig(Compile)(unscoped) ++ inConfig(Test)(unscoped)