I wanna run multiple gradle tasks as one. So instead of
./gradlew clean build publish
I want to have a custom task
./gradl
Here is how I did it, with Kotlin scripting, using both dependsOn and mustRunAfter. Here is an example of running two tasks, one (custom registered "importUnicodeFiles" task) that is in "this" project and one (predefined "run" task) that is in a sibling project named ":unicode":
tasks.register("rebuildUnicodeFiles") {
description = "Force the rebuild of the `./src/main/resources/text` data"
val make = project(":unicode").tasks["run"]
val copy = tasks["importUnicodeFiles"]
dependsOn(make)
dependsOn(copy)
copy.mustRunAfter(make)
}
Try below way to make cleanBuildPublish depend on other tasks
build.gradle
task clean{
println "lets clean"
}
task build {
println "lets build"
}
task publish {
println "lets publish"
}
task cleanBuildPublish{
println 'lets do all'
}
cleanBuildPublish.dependsOn clean
cleanBuildPublish.dependsOn build
cleanBuildPublish.dependsOn publish
Output
$ gradle cleanBuildPublish
lets clean
lets build
lets publish
lets do all
:build UP-TO-DATE
:clean UP-TO-DATE
:publish UP-TO-DATE
:cleanBuildPublish UP-TO-DATE
BUILD SUCCESSFUL
Total time: 2.738 secs
check https://docs.gradle.org/current/userguide/more_about_tasks.html#addDependencyUsingTask for more details