Multi project build with flat folder hierarchy

Is it possible to create multi project build configuration, but with flat folder hierarchy?

What I’m trying to do is those requirement.
Each project (service), will have separate repository,
and I want to share between them common configuration/dependencies/tasks.
And so I can benefit for recompiling dependent sub-project when I’m working on another sub-proejct.

Example of folder structure:

  • parent
  • sub_project1
  • sub_project2
  • commons

Ideally I’ll will create parent project, and inside put all sub-projects, so I can extend parent configuration. But in that case I’ll have git repositories (sub-project) inside parent git repository, which mean git subtrees, and I want to avoid that.


The section of the user guide on Multi-project Builds gives instructions to create a multi-project build with either a hierarchical or flat directory structure. The following section on Initialization also states that your ‘parent’ project should be named ‘master’ if you want to be able to run a flat multi-project build from the sub-projects as well. Otherwise you can only run in the parent project in order for your settings.gradle file to be located and used.

However, you seem to be losing any benefits of having each service in a separate repository. With the build configuration you have described, you can’t just clone a single repository and build that sub-project without also cloning the parent repository (in the correct location). You would also need to clone the other sub-projects or have a more complex settings.gradle setup.

Based on the desire to share build configuration, you might get more benefit from creating a custom plugin to use in each of the services if your main reason for creating a multi-project build is to share build configuration.


yes, main idea is to share some common build configuration.
I like idea to have custom plugin, I’ll definitely consider that idea.

Thanks for the advice!

hi Davor,

what about gradle composite build?

Yes, composite build solves this problem those days.
But not couple months ago :slight_smile:

anyway thx!