Is it somehow possible to not execute the dependencies of a task when that task will be skipped?
In the example below, I'd like jar
(and the dependencies of jar
) to not be executed if a server is already running when executing runServerTests
. The server would in this case be started by another process.
apply plugin: 'java'
task startServerIfNotRunning(dependsOn: jar) {
onlyIf { isServerNotRunning() }
...
}
task runServerTests(dependsOn: startServerIfNotRunning) { ... }
I'd rather not add an onlyIf
to the jar
task, since other tasks that always should be executed may be depending on that one. The jar
task also has dependencies of its own.