Skipping a task if a dependent task is up-to-date?


(Marcin Erdmann) #1

We have some functional tests in our project for which we need to start up an application and then shut it down after the tests have finished. Starting up takes some time and we would like to avoid it if the test won’t run because they are up-to-date.

Is there a way to check if some other task is up-to-date inside of an onlyIf {} condition? I found that during execution SkipUpToDateTaskExecuter is using TaskArtifactStateRepository to retrieve a TaskArtifactState to check if it’s up to date but all these classes are internal.


(Luke Daley) #2

There’s no way to do exactly this without touching internals.

If you can move the setup into a doFirst {} you’ll get the behaviour you want.


(Marcin Erdmann) #3

Thanks Luke, will look into that.

Do you think a new type of task dependency for such scenarios would be something worth adding to the core?


(Luke Daley) #4

The long term idea here is to solve this by allowing arbitrary levels of composition. You’d create a kind of composite task that incorporates both parts, and effectively allowing you to export inputs/outputs to the outer layer.

As for whether it’s worth adding something else in the mean time, would be worth raising as an idea on the dev list.