Forward `run` task to `bgRun`

Fixes #3425

The `Compile`-specific `run` task was removed in #2936 in favor of `bgRun` but it stop short of delegating the `run` to `bgRun`.
This commit is contained in:
Eugene Yokota 2017-08-26 16:48:10 -04:00
parent 88f3d43b87
commit b6f2fe7654
3 changed files with 17 additions and 10 deletions

View File

@ -503,8 +503,8 @@ object Defaults extends BuildCommon {
selectMainClass := mainClass.value orElse askForMainClass(discoveredMainClasses.value),
mainClass in run := (selectMainClass in run).value,
mainClass := pickMainClassOrWarn(discoveredMainClasses.value, streams.value.log),
runMain := runMainTask(fullClasspath, runner in run).evaluated,
run := runTask(fullClasspath, mainClass in run, runner in run).evaluated,
runMain := foregroundRunMainTask.evaluated,
run := foregroundRunTask.evaluated,
copyResources := copyResourcesTask.value,
// note that we use the same runner and mainClass as plain run
bgRunMain := bgRunMainTask(exportedProductJars,
@ -1540,8 +1540,11 @@ object Defaults extends BuildCommon {
lazy val configSettings
: Seq[Setting[_]] = Classpaths.configSettings ++ configTasks ++ configPaths ++ packageConfig ++ Classpaths.compilerPluginConfig ++ deprecationSettings
lazy val compileSettings
: Seq[Setting[_]] = configSettings ++ (mainBgRunMainTask +: mainBgRunTask +: addBaseSources) ++ Classpaths.addUnmanagedLibrary
lazy val compileSettings: Seq[Setting[_]] =
configSettings ++
(mainBgRunMainTask +: mainBgRunTask +: addBaseSources) ++
Classpaths.addUnmanagedLibrary
lazy val testSettings: Seq[Setting[_]] = configSettings ++ testTasks
lazy val itSettings: Seq[Setting[_]] = inConfig(IntegrationTest)(testSettings)

View File

@ -1,6 +1,9 @@
scalaVersion in ThisBuild := "2.12.3"
libraryDependencies ++= Seq(
"com.novocode" % "junit-interface" % "0.5" % "test",
"junit" % "junit" % "4.8" % "test"
"com.novocode" % "junit-interface" % "0.5" % Test,
"junit" % "junit" % "4.8" % Test,
"commons-io" % "commons-io" % "2.5" % Runtime,
)
libraryDependencies += scalaVersion("org.scala-lang" % "scala-compiler" % _ ).value

View File

@ -28,10 +28,11 @@ class Foo {
catch { case _: URISyntaxException => new File(url.getPath) }
}
object Test
{
def main(args: Array[String])
{
object Test {
def main(args: Array[String]): Unit = {
// test that Runtime configuration is included
Class.forName("org.apache.commons.io.ByteOrderMark")
val foo = new Foo
args.foreach { arg => foo.eval(arg) == arg.toInt }
}