I have the following multi-module project structure.
Root project 'reports-be'
+--- Project ':auth'
+--- Project ':builder'
| +--- Project ':builder:base'
| \--- Project ':builder:reporting'
\--- Project ':common'
When I run build
task for /builder subproject and I expect that build
task will be executed for all subprojects (for :builder:base
and :builder:reporting
).
gradle clean :builder:build
But gradle execute build
task only for subproject :builder
.
According Gradle documentation build
task should be completed for all subprojects.
Why doesn't it happen?
P.S. I found that the command gradle -p builder clean build
works as I expected. But I really don't understand what is wrong with first mentioned gradle task.
P.S.S. I have build.gradle
in every subproject and my settings.gradle
looks like
rootProject.name = 'reports-be'
include 'common'
include 'builder'
include 'auth'
include 'builder:base'
include 'builder:reporting'
:builder:build
is a qualified task name of the task build
in the project :builder
, so only this one task (and its dependencies) will be executed. The execution in all (sub-)projects is only possible for unqualified task names as build
. You may switch to the builder
directory and run gradle build
from there, however this approach won't work if you want to run clean
for all projects in the same invocation and it's kind of ugly when using the wrapper (gradlew
). As far as I know, there is no direct solution for your use case.
If I get you right, the :builder
project is just a dummy project for organization purposes and does not contain any actual sources or anything else to build. In this case, you may solve your problems using task dependencies inside builder/build.gradle
:
task build {
dependsOn ':builder:base:build', ':builder:reporting:build'
}