Reputation: 11
Anyone knows how to get B to always run after A even if I only use 'gradle A' on the command line? My first thought was that I could use mustRunAfter, but that seems to require me to specify B on the command line.
task A << {
println 'A'
}
task B << {
println 'B'
}
Upvotes: 1
Views: 401
Reputation: 123996
The (only) way to do so (not counting hacks) is A finalizedBy B
. Note that this will run B
even if A
failed.
Upvotes: 4
Reputation: 17366
You need to use dependsOn feature in Gradle task.
For ex: If you run "gradle ohohWorldTask", it'll always calls myHelloTask to echo "hello" first.
// Say hello
task myHelloTask() << {
println "hello"
}
// Say world
//task ohohWorldTask( dependsOn: [ myHelloTask ] ) << {
//or - using the above you can specify multiple tasks comma separated within [ aTask, bTask, cTask ]
task ohohWorldTask( dependsOn: myHelloTask ) << {
println "-- World!"
}
Upvotes: -2