Understanding 3-level multiprojects


(Steve Cohen) #1

The User’s Guide, Section 24 says

A multi-project build in gradle consists of one root project, and one or more subprojects that may also have subprojects.

(emphasis mine)

I am trying to understand what this means in my situation. I typically have two-level projects. The subprojects apply plugins with the task ‘rpm’ and then at the top level I can issue the command ./gradlew clean rpm and each rpm is built by the subprojects.

Now I want to have a three-level hierarchy. Again, only the lowest level subprojects have rpm tasks. But when I issue
./gradlew clean rpm from the top level or ../gradlew clean rpm from the middle level, it complains

Task ‘rpm’ not found in root project

What must I do to make this sort of setup work?


(Steve Cohen) #2

I think my problem is having settings.gradle at the top and middle layers. According to this old post, this is not supported. I must instead use include 'midlevel:bottomlevel' in the top-level settings.gradle, i.e. the only settings.gradle.


(Mark Vieira) #3

This is correct. A single Gradle multi-project can have only one settings.gradle file.


(Steve Cohen) #4

Thanks. You guys might think about explicitly documenting this, somewhere in Section 24.