See my-tasks.gradle
.
Demonstrates the following concepts:
- Creating custom tasks with dependencies:
taskB
is dependent ontaskA
. - Using upToDateWhen
to to only run
taskB
iftaskA
also ran. - Using onlyIf
to optionally disable
taskA
if theskip
command-line property is specified. - How to use afterEvaluate to make a
task a dependency of another task.
In this case, we make all
Test
tasks dependent on my custom tasktaskB
.
Examples:
Execute both taskA and taskB before running the unit tests:
./gradlew testDebug
Skip both taskA and taskB:
./gradlew testDebug -Pskip
Also see how to use setDidWork in your task action for even more flexibility...