diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index e65a102ab..4a7bd4644 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -2461,7 +2461,11 @@ trait BuildExtra extends BuildCommon with DefExtra { // public API /** Returns a vector of settings that create custom run input task. */ - def fullRunInputTask(scoped: InputKey[Unit], config: Configuration, mainClass: String, baseArguments: String*): Vector[Setting[_]] = + def fullRunInputTask(scoped: InputKey[Unit], config: Configuration, mainClass: String, baseArguments: String*): Vector[Setting[_]] = { + // Use Def.inputTask with the `Def.spaceDelimited()` parser + def inputTask[T](f: TaskKey[Seq[String]] => Initialize[Task[T]]): Initialize[InputTask[T]] = + InputTask.apply(Def.value((s: State) => Def.spaceDelimited()))(f) + Vector( scoped := (inputTask { result => (initScoped(scoped.scopedKey, runnerInit) @@ -2473,6 +2477,8 @@ trait BuildExtra extends BuildCommon with DefExtra { } }).evaluated ) ++ inTask(scoped)(forkOptions := forkOptionsTask.value) + } + // public API /** Returns a vector of settings that create custom run task. */ def fullRunTask(scoped: TaskKey[Unit], config: Configuration, mainClass: String, arguments: String*): Vector[Setting[_]] = @@ -2505,11 +2511,8 @@ trait DefExtra { private[this] val ts: TaskSequential = new TaskSequential {} implicit def toTaskSequential(d: Def.type): TaskSequential = ts } -trait BuildCommon { - @deprecated("Use Def.inputTask with the `Def.spaceDelimited()` parser.", "0.13.0") - def inputTask[T](f: TaskKey[Seq[String]] => Initialize[Task[T]]): Initialize[InputTask[T]] = - InputTask.apply(Def.value((s: State) => Def.spaceDelimited()))(f) +trait BuildCommon { /** * Allows a String to be used where a `NameFilter` is expected. * Asterisks (`*`) in the string are interpreted as wildcards. diff --git a/sbt/src/sbt-test/actions/cross/build.sbt b/sbt/src/sbt-test/actions/cross/build.sbt index f5c3dc75f..6d1b52a23 100644 --- a/sbt/src/sbt-test/actions/cross/build.sbt +++ b/sbt/src/sbt-test/actions/cross/build.sbt @@ -10,11 +10,11 @@ scalaVersion in update := { } } -InputKey[Unit]("check") := (inputTask { argsT => - (argsT, scalaVersion in ThisBuild, scalaVersion, scalaVersion in update) map { (args, svTB, svP, svU) => - def check(label: String, i: Int, actual: String) = assert(args(i) == actual, "Expected " + label + "='" + args(i) + "' got '" + actual + "'") - check("scalaVersion in ThisBuild", 0, svTB) - check("scalaVersion", 1, svP) - check("scalaVersion in update", 2, svU) - } -}).evaluated +InputKey[Unit]("check") := { + val args = Def.spaceDelimited().parsed + def check(label: String, i: Int, actual: String) = + assert(args(i) == actual, s"Expected $label='${args(i)}' got '$actual'") + check("scalaVersion in ThisBuild", 0, scalaVersion in ThisBuild value) + check("scalaVersion", 1, scalaVersion.value) + check("scalaVersion in update", 2, scalaVersion in update value) +} diff --git a/sbt/src/sbt-test/actions/state/build.sbt b/sbt/src/sbt-test/actions/state/build.sbt index 2f9bdb5f2..7e0f67402 100644 --- a/sbt/src/sbt-test/actions/state/build.sbt +++ b/sbt/src/sbt-test/actions/state/build.sbt @@ -27,12 +27,13 @@ lazy val root = (project in file(".")). def demoState(s: State, i: Int): State = s put (sample, i + 1) -def checkInit: Initialize[InputTask[Unit]] = InputTask( (_: State) => token(Space ~> IntBasic) ~ token(Space ~> IntBasic).?) { key => - (key, updateDemo, state) map { case ((curExpected, prevExpected), value, s) => - val prev = s get sample - assert(value == curExpected, "Expected current value to be " + curExpected + ", got " + value) - assert(prev == prevExpected, "Expected previous value to be " + prevExpected + ", got " + prev) - } +def checkInit: Initialize[InputTask[Unit]] = Def inputTask { + val key = (token(Space ~> IntBasic) ~ token(Space ~> IntBasic).?).parsed + val (curExpected, prevExpected) = key + val value = updateDemo.value + val prev = state.value get sample + assert(value == curExpected, s"Expected current value to be $curExpected, got $value") + assert(prev == prevExpected, s"Expected previous value to be $prevExpected, got $prev") } def inMemorySetting = keep := (getPrevious(keep) map { case None => 3; case Some(x) => x + 1} keepAs(keep)).value diff --git a/sbt/src/sbt-test/apiinfo/unstable-existential-names/build.sbt b/sbt/src/sbt-test/apiinfo/unstable-existential-names/build.sbt index ec0b0288c..90c322356 100644 --- a/sbt/src/sbt-test/apiinfo/unstable-existential-names/build.sbt +++ b/sbt/src/sbt-test/apiinfo/unstable-existential-names/build.sbt @@ -1,12 +1,12 @@ import sbt.internal.inc.Analysis // checks number of compilation iterations performed since last `clean` run -InputKey[Unit]("check-number-of-compiler-iterations") := (inputTask { (argTask: TaskKey[Seq[String]]) => - (argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) => - assert(args.size == 1) - val expectedIterationsNumber = args(0).toInt - val allCompilationsSize = a.compilations.allCompilations.size - assert(allCompilationsSize == expectedIterationsNumber, - "allCompilationsSize == %d (expected %d)".format(allCompilationsSize, expectedIterationsNumber)) - } -}).evaluated +InputKey[Unit]("check-number-of-compiler-iterations") := { + val args = Def.spaceDelimited().parsed + val a = (compile in Compile).value.asInstanceOf[Analysis] + assert(args.size == 1) + val expectedIterationsNumber = args(0).toInt + val allCompilationsSize = a.compilations.allCompilations.size + assert(allCompilationsSize == expectedIterationsNumber, + "allCompilationsSize == %d (expected %d)".format(allCompilationsSize, expectedIterationsNumber)) +} diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt b/sbt/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt index f671d44fc..59de073d7 100644 --- a/sbt/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt @@ -3,10 +3,13 @@ import sbt.internal.inc.Analysis logLevel := Level.Debug // dumps analysis into target/analysis-dump.txt file -InputKey[Unit]("check-number-of-compiler-iterations") := (inputTask { (argTask: TaskKey[Seq[String]]) => - (argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) => - assert(args.size == 1) - val expectedIterationsNumber = args(0).toInt - assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber)) - } -}).evaluated +InputKey[Unit]("check-number-of-compiler-iterations") := { + val args = Def.spaceDelimited().parsed + val a = (compile in Compile).value.asInstanceOf[Analysis] + assert(args.size == 1) + val expectedIterationsNumber = args(0).toInt + assert( + a.compilations.allCompilations.size == expectedIterationsNumber, + "a.compilations.allCompilations.size = %d (expected %d)".format( + a.compilations.allCompilations.size, expectedIterationsNumber)) +} diff --git a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt index 66128f225..4a78ef4e7 100644 --- a/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt +++ b/sbt/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt @@ -1,9 +1,11 @@ import sbt.internal.inc.Analysis -InputKey[Unit]("check-number-of-compiler-iterations") := (inputTask { (argTask: TaskKey[Seq[String]]) => - (argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) => - assert(args.size == 1) - val expectedIterationsNumber = args(0).toInt - assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber)) - } -}).evaluated +InputKey[Unit]("check-number-of-compiler-iterations") := { + val args = Def.spaceDelimited().parsed + val a = (compile in Compile).value.asInstanceOf[Analysis] + assert(args.size == 1) + val expectedIterationsNumber = args(0).toInt + assert(a.compilations.allCompilations.size == expectedIterationsNumber, + "a.compilations.allCompilations.size = %d (expected %d)".format( + a.compilations.allCompilations.size, expectedIterationsNumber)) +} diff --git a/sbt/src/sbt-test/dependency-management/override/build.sbt b/sbt/src/sbt-test/dependency-management/override/build.sbt index 5e3652c8d..45c5f6222 100644 --- a/sbt/src/sbt-test/dependency-management/override/build.sbt +++ b/sbt/src/sbt-test/dependency-management/override/build.sbt @@ -3,14 +3,13 @@ autoScalaLibrary := false ivyPaths := (baseDirectory, target)( (dir, t) => IvyPaths(dir, Some(t / "ivy-cache"))).value ivyScala := ((scalaVersion in update, scalaBinaryVersion in update) { (fv, bv) => - Some(IvyScala(fv, bv, Vector.empty, filterImplicit = false, checkExplicit = false, overrideScalaVersion = false)) + Some(IvyScala(fv, bv, Vector.empty, filterImplicit = false, checkExplicit = false, overrideScalaVersion = false)) }).value -InputKey[Unit]("check") := (inputTask { args => - (update, args) map { - case (report, Seq(expected, _*)) => - report.allModules.forall(_.revision == expected) - } -}).evaluated +InputKey[Unit]("check") := { + val args = Def.spaceDelimited().parsed + val Seq(expected, _*) = args + update.value.allModules.forall(_.revision == expected) +} scalaVersion := "2.9.1" diff --git a/sbt/src/sbt-test/project/load-hooks/build.sbt b/sbt/src/sbt-test/project/load-hooks/build.sbt index 93067dfbe..c5d44543c 100644 --- a/sbt/src/sbt-test/project/load-hooks/build.sbt +++ b/sbt/src/sbt-test/project/load-hooks/build.sbt @@ -11,14 +11,14 @@ ) } -InputKey[Unit]("checkCount") := (inputTask { argsTask => - (argsTask, state) map { (args, s) => - def get(label: String) = s get AttributeKey[Int](label) getOrElse 0 - val loadCount = get("load-count") - val unloadCount = get("unload-count") - val expectedLoad = args(0).toInt - val expectedUnload = args(1).toInt - assert(expectedLoad == loadCount, "Expected load count: " + expectedLoad + ", got: " + loadCount) - assert(expectedUnload == unloadCount, "Expected unload count: " + expectedUnload + ", got: " + unloadCount) - } -}).evaluated +InputKey[Unit]("checkCount") := { + val s = state.value + val args = Def.spaceDelimited().parsed + def get(label: String) = s get AttributeKey[Int](label) getOrElse 0 + val loadCount = get("load-count") + val unloadCount = get("unload-count") + val expectedLoad = args(0).toInt + val expectedUnload = args(1).toInt + assert(expectedLoad == loadCount, s"Expected load count: $expectedLoad, got: $loadCount") + assert(expectedUnload == unloadCount, s"Expected unload count: $expectedUnload, got: $unloadCount") +} diff --git a/sbt/src/sbt-test/source-dependencies/abstract-type-override/build.sbt b/sbt/src/sbt-test/source-dependencies/abstract-type-override/build.sbt index fbdcd84fe..b0d683951 100644 --- a/sbt/src/sbt-test/source-dependencies/abstract-type-override/build.sbt +++ b/sbt/src/sbt-test/source-dependencies/abstract-type-override/build.sbt @@ -1,9 +1,12 @@ import sbt.internal.inc.Analysis -InputKey[Unit]("checkNumberOfCompilerIterations") := (inputTask { (argTask: TaskKey[Seq[String]]) => - (argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) => - assert(args.size == 1) - val expectedIterationsNumber = args(0).toInt - assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber)) - } -}).evaluated +InputKey[Unit]("checkNumberOfCompilerIterations") := { + val a = (compile in Compile).value.asInstanceOf[Analysis] + val args = Def.spaceDelimited().parsed + assert(args.size == 1) + val expectedIterationsNumber = args(0).toInt + assert(a.compilations.allCompilations.size == expectedIterationsNumber, + "a.compilations.allCompilations.size = %d (expected %d)".format( + a.compilations.allCompilations.size, expectedIterationsNumber) + ) +}