如何在Gradle中的主目录中包含多项目构建中的项目? [英] How to include projects in multiproject build from master directory in Gradle?
问题描述
让我们有这样的结构
我在 subproject1 中编写 settings.gradle 文件以包含 subproject1 和 subproject2 作为根项目的子项目。我的 settings.gradle 文件位于 master 目录中?
我试过:
include'root:subproject1','root:subproject2'
但没有发生任何事情。
从Gradle文档:
如果您在没有settings.gradle文件的项目中执行Gradle,Gradle将执行以下操作:
它在名为 master 的目录中搜索settings.gradle,该目录与当前目录具有相同的嵌套级别。
如果没有设置找到.gradle 后,它会搜索父目录中是否存在settings.gradle文件。 如果找不到 settings.gradle 文件,构建将作为单个项目构建执行。
includeFlat 'subproject1','subproject2'
includeFlat
是 include
-ing项目,然后根据平面目录布局设置它们的 projectDir
s的简短形式。
有关更多信息,请参阅 Gradle用户指南,并且示例以完整的Gradle发行版构建。
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.
includeFlat 'subproject1', 'subproject2'
includeFlat
is a short form for include
-ing the projects and then setting their projectDir
s 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.
这篇关于如何在Gradle中的主目录中包含多项目构建中的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!