Drop deprecated inputTask method

Temporarily (FLW) duplicate it in fullRunInputTask.
This commit is contained in:
Dale Wijnand 2017-04-11 13:29:05 +01:00
parent 91354497ab
commit 6820bcf99c
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
9 changed files with 78 additions and 67 deletions

View File

@ -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.

View File

@ -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)
}

View File

@ -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

View File

@ -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))
}

View File

@ -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))
}

View File

@ -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))
}

View File

@ -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"

View File

@ -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")
}

View File

@ -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)
)
}