Reputation: 180
I've got a very basic multi-project Gradle setup like this:
root
+--- build.gradle
+--- settings.gradle
+--- subproject1
\--- build.gradle
\--- subproject2
\--- build.gradle
The settings.gradle
file includes both subprojects. The root project does not apply the java plugin, but both subprojects do. Everything builds as expected when using gradle build
.
But, as far as i understand, since i don't apply the java
plugin at the root project, it is not supposed to have a build
task.
gradle tasks
, shows a build
task.gradle tasks --all
shows only :subproject1:build
and :subproject2:build
listed instead.So my question is - what exactly is executed in this scenario? Does gradle just find every task that matches the supplies pattern in all subprojects? Are there any specific rules about this task name resolution? Where can i find more info about this?
Upvotes: 4
Views: 3031
Reputation: 38734
Yes, you are right. If you do use just a task name or task name abbreviation, the task is executed in all subprojects of the current directory. If you want to only call subporject1
s build
task, either use the absolute path to it with gradle :subproject1:build
or a relative path. If you are in the root directory e. g. the relative path would be gradle subproject1:build
.
You can read more about it at https://docs.gradle.org/current/userguide/intro_multi_project_builds.html#N10762.
Btw. you should consider using the Gradle Wrapper. Each and every project jusing Gradle should also use the Gradle Wrapper. It is one of the most effective strengts of Gradle, as you need only Java installed, not Gradle or Maven or ant or anything else and the build always runs with the Gradle version you designed it to run with.
Upvotes: 1