Make a difference between running order and dependencies
See original GitHub issueA dependency is something that HAS to be run before something else. If it does not have to be run, it should allow the task to run anyway.
Task("First")
.WithCriteria(() => shouldDoStuff)
.Does(() =>
{
});
Task("Second")
.RunsAfter("First")
.Does(() =>
{
});
Task("Third")
.IsDependentOn("Second")
.Does(() =>
{
});
In the example before, the task Second
will be run regardless if shouldDoStuff
was true or not, Third
is dependent on Second
though, so if Second
did not run, an exception will be thrown.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Gradle: how does order of dependencies make a difference?
Yes, the first class matching the FQN is loaded in the order of the classpath declaration (which is build using the dependencies order)....
Read more >Understanding Task Dependencies in Project Management
Dependencies are the relationships among tasks which determine the order in which activities need to be performed. There are four (4) types of...
Read more >Dependencies and ordering of tests - Testim overview
Different aspects of dependencies and ordering of tests. ... so you can add prefix numbers to your tests to make Testim run in...
Read more >Understanding Dependencies in Project Management [2023]
A project dependency is a task that relies on the completion of a different task. This article discusses different dependencies in project ...
Read more >Everything You Need to Know About Task Dependencies
A task dependency represents the order you should complete the tasks for an optimal project outcome. Put another way: a task dependency is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve been burned a few times by having a dependent task run even though the “parent” task’s
WithCriteria
clause was false.For example:
Since
runIntegrationTests
is false, I would not expect any of “Provision VM”, “Execute Integration Tests”, nor “Tear Down VM” to be executed.I’m not saying this solves the problem, but what is the reason for evaluating the
WithCriteria
clause after executing dependent tasks rather than before? Or does evaluatingWithCriteria
before introduce a similarly-large problem for other use cases?I think my initial understanding/expectation of how
IsDependentOn
interacts withWithCriteria
is/was just wrong.The docs say the following about
WithCriteria
:Given that description, it wasn’t clear to me that criteria and dependencies are basically two completely separate features.
My personal thoughts would be to do one of the following:
IsDependentOn
isn’t going to change, update the docs to clarify how criteria and dependencies interact first/separately from the existing example that illustrates definition-time vs. execution-time criteria evaluation.IsDependentOn
works, if it’s really meant to define the dependency graph, it feels likeWithCriteria
should cascade by default (imho) (i.e., if Task A has criteria and also depends on Task B, but Task A does not run due to its criteria, then Task B should not run either).If the above causes too many other problems, yes, something like
WithCascadingCriteria
would help, or as you’ve suggested in https://github.com/cake-build/cake/issues/29#issuecomment-125054641, possibly rename the existingIsDependentOn
to something more likeRunsAfter
and makeIsDependentOn
work as outlined above to provide different registration options depending what you’re trying to do.