是否可以建立一个超过2级的gradle项目? [英] Is it possible to set up a gradle project with more than 2 levels?
问题描述
所有我见过的用于gradle的示例都有一个根项目和一个子项目级别。出于各种原因,我们希望整合我们的git项目。所有这些都是gradle项目,其中一些项目有gradle子项目。我们最终想要的是一个多层次的gradle结构。我们不想改变所有这些项目的gradle设置,而是希望拥有一个管理所有项目和相应子项目的顶级gradle。我的第一次尝试表明,我不能拥有一个控制build.gradle编排所有项目和子项目。难道我做错了什么?我是否遵循和固有地打破了范式?
以下是我想要做的示例结构:
顶部工程
build.gradle $ b $工程
build.gradle
子工程
build.gradle
src
子项目
...
项目
...
<
我会简单地将以下内容放入TopProject / settings.gradle:
include'Project1:SubProject1'
include'Project1:SubProject2'
包括'Project2:SubProject1'
...
目前需要从它们中删除settings.gradle文件,因为每个项目结构只能有一个setting.gradle文件。
We have been using gradle for about a year and have been somewhat successful with it. A number of features are still a little opaque, but we are getting there. I am not sure I am going about solving the problem correctly, so I will go ahead and ask the question:
All the examples that I have seen for gradle have a root project and one level of sub-projects. For a number of reasons, we would like to consolidate our git projects. All of these are gradle projects, some of which have gradle sub-projects. What we want to end up with is essentially a multi-level gradle structure. We do not want to alter the gradle setup for all those projects and instead would like to have a top level gradle that manages all the projects and corresponding subprojects. My first attempt showed that I cannot have a controlling build.gradle that orchestrates all of the projects and subprojects. Am I doing something wrong? Am I following and inherently broken paradigm?
Here is a sample structure for what I want to do:
Top Project
build.gradle
Project
build.gradle
Sub Project
build.gradle
src
Sub Project
...
Project
...
Thank you and I hope I did not miss some obvious explanation in the documentation.
I would simply put the following in TopProject/settings.gradle:
include 'Project1:SubProject1'
include 'Project1:SubProject2'
include 'Project2:SubProject1'
...
The only change required to the projects you currently have is to remove settings.gradle files from them as you can only have one setting.gradle file per project structure.
这篇关于是否可以建立一个超过2级的gradle项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!