gradlesettingsprojectmulti-project

How to include projects in multiproject build from master directory in Gradle?


Lets have this structure

enter image description here

I am in subproject1 how to write my settings.gradle file to include subproject1 and subproject2 as subprojects of the root Project. My settings.gradle file is in master directory?

I tried:

include 'root:subproject1', 'root:subproject2'

but nothing happened.

From Gradle doc:

If you execute Gradle from within a project that has no settings.gradle file, Gradle does the following:


Solution

  • includeFlat 'subproject1', 'subproject2'
    

    includeFlat is a short form for include-ing the projects and then setting their projectDirs as appropriate for a flat directory layout.

    For more information, see the "Multi-project builds" chapter in the Gradle User Guide, and the sample builds in the full Gradle distribution.