From 92807869ead875bc3d7085905fc70e7e9f2487df Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Wed, 30 Jan 2019 20:49:56 -0800 Subject: [PATCH] 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. --- main/src/main/scala/sbt/Defaults.scala | 37 ++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 6d0590334..f5749a935 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -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)