mirror of https://github.com/sbt/sbt.git
Propagate taskDefinitionKey in Incompletes from flatMaps. Ref #784.
This commit is contained in:
parent
5a252fae3a
commit
fb27f5558c
|
|
@ -156,8 +156,13 @@ object EvaluateTask
|
||||||
val tags = tagged[Task[_]](_.info get tagsKey getOrElse Map.empty, Tags.predicate(config.restrictions))
|
val tags = tagged[Task[_]](_.info get tagsKey getOrElse Map.empty, Tags.predicate(config.restrictions))
|
||||||
val (service, shutdown) = completionService[Task[_], Completed](tags, (s: String) => log.warn(s))
|
val (service, shutdown) = completionService[Task[_], Completed](tags, (s: String) => log.warn(s))
|
||||||
|
|
||||||
|
// propagate the defining key for reporting the origin
|
||||||
|
def overwriteNode(i: Incomplete): Boolean = i.node match {
|
||||||
|
case Some(t: Task[_]) => transformNode(t).isEmpty
|
||||||
|
case _ => true
|
||||||
|
}
|
||||||
def run() = {
|
def run() = {
|
||||||
val x = new Execute[Task](config.checkCycles, triggers)(taskToNode)
|
val x = Execute[Task]( Execute.config(config.checkCycles, overwriteNode), triggers)(taskToNode)
|
||||||
val (newState, result) =
|
val (newState, result) =
|
||||||
try applyResults(x.runKeep(root)(service), state, root)
|
try applyResults(x.runKeep(root)(service), state, root)
|
||||||
catch { case inc: Incomplete => (state, Inc(inc)) }
|
catch { case inc: Incomplete => (state, Inc(inc)) }
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ object Load
|
||||||
|
|
||||||
// map dependencies on the special tasks:
|
// map dependencies on the special tasks:
|
||||||
// 1. the scope of 'streams' is the same as the defining key and has the task axis set to the defining key
|
// 1. the scope of 'streams' is the same as the defining key and has the task axis set to the defining key
|
||||||
// 2. the defining key is stored on constructed tasks
|
// 2. the defining key is stored on constructed tasks: used for error reporting among other things
|
||||||
// 3. resolvedScoped is replaced with the defining key as a value
|
// 3. resolvedScoped is replaced with the defining key as a value
|
||||||
// Note: this must be idempotent.
|
// Note: this must be idempotent.
|
||||||
def finalTransforms(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
def finalTransforms(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,12 @@ object Execute
|
||||||
def process() { p }
|
def process() { p }
|
||||||
}
|
}
|
||||||
def noTriggers[A[_]] = new Triggers[A](Map.empty, Map.empty, idFun)
|
def noTriggers[A[_]] = new Triggers[A](Map.empty, Map.empty, idFun)
|
||||||
|
|
||||||
|
def apply[A[_] <: AnyRef](config: Config, triggers: Triggers[A])(implicit view: NodeView[A]): Execute[A] =
|
||||||
|
new Execute(config, triggers)(view)
|
||||||
|
|
||||||
|
def config(checkCycles: Boolean, overwriteNode: Incomplete => Boolean = const(false)): Config = new Config(checkCycles, overwriteNode)
|
||||||
|
final class Config private[sbt](val checkCycles: Boolean, val overwriteNode: Incomplete => Boolean)
|
||||||
}
|
}
|
||||||
sealed trait Completed {
|
sealed trait Completed {
|
||||||
def process(): Unit
|
def process(): Unit
|
||||||
|
|
@ -30,8 +36,11 @@ trait NodeView[A[_]]
|
||||||
}
|
}
|
||||||
final class Triggers[A[_]](val runBefore: collection.Map[A[_], Seq[A[_]]], val injectFor: collection.Map[A[_], Seq[A[_]]], val onComplete: RMap[A,Result] => RMap[A,Result])
|
final class Triggers[A[_]](val runBefore: collection.Map[A[_], Seq[A[_]]], val injectFor: collection.Map[A[_], Seq[A[_]]], val onComplete: RMap[A,Result] => RMap[A,Result])
|
||||||
|
|
||||||
final class Execute[A[_] <: AnyRef](checkCycles: Boolean, triggers: Triggers[A])(implicit view: NodeView[A])
|
final class Execute[A[_] <: AnyRef] private(config: Config, triggers: Triggers[A])(implicit view: NodeView[A])
|
||||||
{
|
{
|
||||||
|
@deprecated("Use Execute.apply", "0.13.0")
|
||||||
|
def this(checkCycles: Boolean, triggers: Triggers[A])(implicit view: NodeView[A]) = this(Execute.config(checkCycles), triggers)(view)
|
||||||
|
|
||||||
type Strategy = CompletionService[A[_], Completed]
|
type Strategy = CompletionService[A[_], Completed]
|
||||||
|
|
||||||
private[this] val forward = idMap[A[_], IDSet[A[_]] ]
|
private[this] val forward = idMap[A[_], IDSet[A[_]] ]
|
||||||
|
|
@ -93,7 +102,7 @@ final class Execute[A[_] <: AnyRef](checkCycles: Boolean, triggers: Triggers[A])
|
||||||
|
|
||||||
def call[T](node: A[T], target: A[T])(implicit strategy: Strategy)
|
def call[T](node: A[T], target: A[T])(implicit strategy: Strategy)
|
||||||
{
|
{
|
||||||
if(checkCycles) cycleCheck(node, target)
|
if(config.checkCycles) cycleCheck(node, target)
|
||||||
pre {
|
pre {
|
||||||
assert( running(node) )
|
assert( running(node) )
|
||||||
readyInv( node )
|
readyInv( node )
|
||||||
|
|
@ -232,7 +241,7 @@ final class Execute[A[_] <: AnyRef](checkCycles: Boolean, triggers: Triggers[A])
|
||||||
def work[T](node: A[T], f: => Either[A[T], T])(implicit strategy: Strategy): Completed =
|
def work[T](node: A[T], f: => Either[A[T], T])(implicit strategy: Strategy): Completed =
|
||||||
{
|
{
|
||||||
val result = wideConvert(f).left.map {
|
val result = wideConvert(f).left.map {
|
||||||
case i: Incomplete => if(i.node.isEmpty) i.copy(node = Some(node)) else i
|
case i: Incomplete => if(config.overwriteNode(i)) i.copy(node = Some(node)) else i
|
||||||
case e => Incomplete(Some(node), Incomplete.Error, directCause = Some(e))
|
case e => Incomplete(Some(node), Incomplete.Error, directCause = Some(e))
|
||||||
}
|
}
|
||||||
completed {
|
completed {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue