I wanna run multiple gradle tasks as one. So instead of
./gradlew clean build publish
I want to have a custom task
./gradlew cleanBuildPublish
that executes clean
build
and publish
in order.
How's that possible?
This does not work
task cleanBuildPublish {
dependsOn 'clean'
dependsOn 'build'
dependsOn 'publish'
}
Best Answer
If you need to execute some tasks in predefined order, then you need to not only set
dependsOn
, but also to setmustRunAfter
property for this tasks, like in the following code:dependsOn
doesn't define an order of tasks execution, it just make one task dependent from another, whilemustRunAfter
does.