Merge pull request #4631 from eatkins/previous

Allow calling TaskKey.previous in input tasks
This commit is contained in:
eugene yokota 2019-04-25 22:48:35 -04:00 committed by GitHub
commit 42bc2ea04d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -450,6 +450,7 @@ object TaskMacro {
def expand(nme: String, tpe: Type, tree: Tree): Converted[c.type] = nme match {
case WrapInitTaskName => Converted.Success(wrapInitTask(tree)(c.WeakTypeTag(tpe)))
case WrapPreviousName => Converted.Success(wrapInitTask(tree)(c.WeakTypeTag(tpe)))
case ParserInput.WrapInitName => Converted.Success(wrapInitParser(tree)(c.WeakTypeTag(tpe)))
case WrapInitInputName => Converted.Success(wrapInitInput(tree)(c.WeakTypeTag(tpe)))
case WrapInputName => Converted.Success(wrapInput(tree)(c.WeakTypeTag(tpe)))

View File

@ -0,0 +1,10 @@
import sjsonnew.BasicJsonProtocol._
val cacheTask = taskKey[Int]("task")
cacheTask := 1
val checkTask = inputKey[Unit]("validate that the correct value is set by cacheTask")
checkTask := {
val expected = Def.spaceDelimited("").parsed.head.toInt
assert(cacheTask.previous.getOrElse(0) == expected)
}

View File

@ -0,0 +1,5 @@
> checkTask 0
> cacheTask
> checkTask 1