Multi-Project Project with Sub-"Masters"


I’d like to have a project hierarchy deeper than one level. An example would be

root -- api ---- apiA ---- apiB ---- apiC -- service ---- serviceX ---- serviceY ---- serviceY

The projects api and service are my middle-level masters. They just should have a build.gradle where some dependencies are defined via subproject command for their child-projects.

The project root would than just contains some general common tasks (like publishing or Junit-Dependencies).

Would this be possible, to build such a hierarchy and make configurations in the two projects (api, service) for their child-projects?

kind regards

Hi Günther,

yes, this is possible. May I ask why you didn’t just try it out? :slightly_smiling:



actually i tried it:


  • root
  • api
  • apiA

build.gradle of root
allprojects { task hello << { task -> println "I'm $" println "My root is $" } }

build.gradle of api
allprojects { task hello2 << { task -> println "I'm a API project $" println "My root is $" } }

settings.gradle (in root)
includeFlat 'api' includeFlat 'api:apiA'

when i call gradlew hello then the output seems fine, because all three projects are contained:
:hello I'm root My root is root :api:hello I'm api My root is root :api:apiA:hello I'm api:apiA My root is root

but when i call gradlew hello2 i miss the output from apiA:
:api:hello2 I'm a API project api My root is root

includeFlat does not allow nested projects. I created an issue for that, as it should either be handled correctly or give a warning.

If you have a project structure that has both “flat” and “nested” parts, you’ll have to use include and then set the projectDir manually. See the user guide on settings.gradle

Thanks a lot. I just will change my hierarchy.

This works exactly as i expected after changing the folders to a hierarchy. Thanks again!