Conditional task dependencies
See original GitHub issueI was just trying to figure out a way to do conditional dependencies between tasks, particularly as a means to get incremental build behavior.
It’s not directly supported through the task DSL, but I figured I’d see if anyone has ideas on how I might achieve this. If not, maybe this would be a nice enhancement 😄
Here’s a simplified example of what I’m trying to do:
Let’s say I have a Build task and a Package task. I only want to run the Build task if my bin is empty (or older than the source files, or whatever). Otherwise, I’ll just package the artifacts that are already in the bin.
Obviously I can set up a WithCriteria
on the Build task, but I don’t really want to the Build task to be responsible for that, as I don’t always want that rule to be applied every time the Build task is invoked – I’d rather apply that condition contextually.
I actually expected that if a Task’s WithCriteria
isn’t satisfied, that the tasks it depends on would not be invoked. That doesn’t seem to be the case, though. The dependencies always get invoked, and only the task with the unsatisfied Criteria gets skipped.
Any thoughts?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:15 (9 by maintainers)
Top GitHub Comments
To solve a scenario similar to that outlined by @jonstelly - a whole group of tasks grouped under the umbrella “package”, with one bool controlling go/no-go for that group - I did the following, for now:
In wider context:
Not offering this as a recommendation, just an example of another workround. I agree that some native syntax would be better.
( @patriksvensson , it was good to meet you at tretton37 in November 😄 )
@devlead, thank you for your feedback. If
subtask
can lead tomain
task condition fail that can add complexity.In my case I have task “tree” where small tasks(actions) are grouped into big task that are group into the biggest 😃
Now, as a workaround, I build task based on criterias like