gradlegradle-task

Execute builds only for some gradle modules in project


I have a project utilities with a build.gradle. utilities has some modules named util, util2, util3, ... In a task I want to execute first :util2:build and :util5:build. But I do not know how to write such a task. This fails:

task executePreBuild() {
:util2:build
:util5:build
}

In commandline

gradlew clean :util2:build :util5:build

can be executed. But this is not my purporse. I want to execute

gradlew clean executePreBuild someOtherTask build


Solution

  • This can be done by using dependsOn:

    task executePreBuild {
        dependsOn ":util2:build"
        dependsOn ":util5:build"
    }