Multi-Project Project with Sub-"Masters"

gradle-3409
issue-acknowledged

(Günther Grill) #1

Hi,

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
Guenther


(Stefan Oehme) #2

Hi Günther,

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

Cheers,
Stefan


(Günther Grill) #3

Hi,

actually i tried it:

Folders:

  • root
  • api
  • apiA

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


(Stefan Oehme) #5

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


(Günther Grill) #6

Thanks a lot. I just will change my hierarchy.


(Günther Grill) #7

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