question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make a difference between running order and dependencies

See original GitHub issue

A 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:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
dbertramcommented, Jun 30, 2016

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:

var runIntegrationTests = Argument<bool>("runIntegrationTests", false);

Task("Default")
    .IsDependentOn("Build")
    .IsDependentOn("Run Unit Tests")
    .IsDependentOn("Run Integration Tests")
;

Task("Run Integration Tests")
    .WithCriteria(runIntegrationTests)
    .IsDependentOn("Provision VM")
    .IsDependentOn("Execute Integration Tests")
    .IsDependentOn("Tear Down VM")
;

// other tasks ...

RunTarget("Default");

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 evaluating WithCriteria before introduce a similarly-large problem for other use cases?

1reaction
dbertramcommented, Jul 5, 2016

I think my initial understanding/expectation of how IsDependentOninteracts with WithCriteria is/was just wrong.

The docs say the following about WithCriteria:

You can control and influence the flow of the build script execution by providing criteria. This is a predicate that has to be fulfilled for the task to execute. The criteria does not affect however succeeding task will be executed.

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:

  1. If the way 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.
  2. If you’re ok with changing how IsDependentOn works, if it’s really meant to define the dependency graph, it feels like WithCriteria 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 existing IsDependentOn to something more like RunsAfter and make IsDependentOn work as outlined above to provide different registration options depending what you’re trying to do.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found