Is there a way to configure one task in such a way that it is skipped when another, future task is up-to-date.
When I run an integrationTest task, I first start a local application server (cargoStartLocal). However, I don’t want to start the application server when the integrationTest task is considered up-to-date. It makes no sense to start the application server, simply to find out that there’s nothing to do.
I thought about wiring the outputs and inputs of the integrationTask to those of cargoStartLocal, but that doesn’t help because the plugin that provides the cargoStartLocal task explicitly sets up-to-date to false (upToDateWhen{false}) and there’s no way in gradle to replace and override that behaviour.
Next thought was to play around with an onlyIf Spec and inside that onlyIf spec I check if the integrationTest task is up-to-date like the following:
cargoStartLocal.onlyIf {
def result = integrationTest.outputs.????
println "integration is up to date: $result"
return !result
}
However, I can’t seem to find a way to manually check if integrationTest will be up-to-date.
However, the plugin that provides the cargoStartLocal task explicitly sets up-to-date to false (upToDateWhen{false}) - for some reason that I don’t understand - and there’s no way in gradle to replace and override that behaviour.
So I’m looking for other ways to do the same thing, and the only thing I could come up with was to specify an onlyIf spec in cargoStartLocal's task where I first check if integrationTest will be up-to-date. However, I cannot find a way to do that because the integrationTest is yet to execute.