Task to build all projects


(Dmitriy Voronin) #1

I have multiproject build with android/java modules
Goal: to have pretty and configurable one liner for CI, like

./gradlew ciBuild

in root build.gradle i create following:

task ciBuild {
      dependsOn subprojects.build
}

Ok, but not working! Because modules obtain build task only after plugin applied, so i wrap it into:

gradle.projectsEvaluated {
    task ciBuild {
        dependsOn subprojects.build
    }
}

So far so good, but it won’t work if i want to enable configure on demand option, this callback just never invoked.
Why i want configure on demand? because i’m working on decoupling my modules and want to have this room for optimization in future.

Are there any alternatives, or this whole idea is just wrong?


(Mark Vieira) #2

You really won’t get any benefit from configure on demand here since you’ll have to configure every project anyhow. You’re basically saying “run task X for every subproject”. Well, to do that, we have to evaluate every subproject, thus negating any benefit from configure on demand. Configure on demand will only benefit you when doing partial builds, for example ./gradlew :someSubProject:build.

Additionally, if you want to run the build task for every project, you can just run ./gradlew build. There is no need to define a special task in the root project.


(Dmitriy Voronin) #3

I will get benefit of configure on demand on dev machine, where i need to run only :oneofmyapps:assemble at a time. And of course i can’t use it on CI environment.

So if i want to add more checks on CI build, i just add build.dependsOn myNewCheck ?


(Mark Vieira) #4

The more idiomatic thing to do would be check.dependsOn myNewCheck. The result when running build would be the same since build depends on check.