I have the following situation:
I have a project with several subprojects. Today I tried to build the projects with gradle via command line.
The build was successful when I executed ./gradlew clean :build
, but not with ./gradlew clean build
. It causes different errors, depending on which subprojects are activated. Why is that? Shouldn't it be the same?
Both commands are executed directly after each other, without changes in the code, and from the same directory (the base-directory, where settings.gradle
is located.
The gradle-refresh of Intellij works, the build is successful (but fails on our build server, if that is relevant).
According to the documentation https://docs.gradle.org/current/userguide/command_line_interface.html#executing_tasks_in_multi_project_builds I assumed that it would do the same, since no subproject is specified, and the build task is executed for all submodules. There is no folder called build
in the root project, so this should not cause confusion. Am I interpreting it wrong?
I searched online, however, I could not find the result, since :
is is not recognized by most search engines, and colon
leads to not relevant results like What is the colon operator in Gradle?.
The gradle version is 4.10.2
If you need more information, please let me know.
./gradlew clean :build
: you execute taskclean
on all projects, but taskbuild
only on the root project, because:build
references a task named "build" in the ":" project (root project). this is different than executing./gradlew clean build
: here you executeclean
on all projects, thenbuild
on all projects. So maybe you have one subproject that has error in build execution: in the first case you won't see this error as you only build the rootProject. – Shorn:build
) executes all build of subprojects too? If not, what does it do? – Sharpwitted:build
if you want to only execute build task on this specific project and not subprojects – Shorn