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?
build.gradle of root allprojects { task hello << { task -> println "I'm $task.project.name" println "My root is $rootProject.name" } }
build.gradle of api allprojects { task hello2 << { task -> println "I'm a API project $task.project.name" println "My root is $rootProject.name" } }
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