假设我想将Gradle
用于项目结构,例如:
RootProject
\-- SubProjectA
\-- SubProjectAA
\-- SubProjectAB
我如何实现这一目标?
我尝试的非常简单。我已经创建了所有目录,其结构如上所述:
RootProject
\-- SubProjectA
\-- SubProjectAA
\-- build.gradle
\-- SubProjectAB
\-- build.gradle
\-- build.gradle
\-- settings.gradle
\-- build.gradle
\-- settings.gradle
RootProject / settings.gradle:
include "SubProjectA"
RootProject / SubProjectA / settings.gradle:
include "SubProjectAA", "SubProjectAB"
我尝试了两件事。首先,我尝试在Eclipse中导入项目 - 它没有检测到SubProjectAA
或SubProjectAB
。惊呆了,我在gradle projects
中运行了RootProject
并得到了这个输出:
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'RootProject'
\--- Project ':SubProjectA'
但是,我认为我犯了一个错误,我尝试在SubProjectA中运行相同的命令,并得到:
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'RootProject'
\--- Project ':SubProjectAA'
\--- Project ':SubProjectAB'
我认为解析子项目不会递归。有没有解决方法呢?
每个例子都被样本名称掩盖,如果我犯了任何错误,对不起。
谢谢!
答案 0 :(得分:21)
您只能拥有一个settings.gradle
。通常它会包含以下内容:
include "SubProjectA:SubProjectAA"
include "SubProjectA:SubProjectAB"
更多信息可以在Gradle User Guide的“多项目构建”一章中找到。
答案 1 :(得分:0)
尝试
RootProject
\-- SubProjectA
\-- SubProjectAA
\-- build.gradle
\-- SubProjectAB
\-- build.gradle
\-- build.gradle
\-- settings.gradle
include ':SubProjectA/SubProjectAA'