How to include projects in multiproject build from

2019-07-31 23:49发布

问题:

Lets have this structure

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:

  • It searches for a settings.gradle in a directory called master which has the same nesting level as the current dir.
  • If no settings.gradle is found, it searches the parent directories for the existence of a settings.gradle file.
  • If no settings.gradle file is found, the build is executed as a single project build.
  • If a settings.gradle file is found, Gradle checks if the current project is part of the multiproject hierarchy defined in the found settings.gradle file. If not, the build is executed as a single project build. Otherwise a multiproject build is executed.

回答1:

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.