gpt4 book ai didi

eclipse - 如何允许/解决嵌套复合Gradle构建

转载 作者:行者123 更新时间:2023-12-03 14:50:02 27 4
gpt4 key购买 nike

我遇到了与here报告相同的问题:

I have a Java project A which depends on project B (module), and project B dependes on project C (another module). For project A I would like to setup "includeBuild ../projectB" and for project B I would like too setup "includeBuild ../projectC" so that I could develop everything in Eclipse + Buildship 2.0 without the need to run Gradle for every small change in each of the projecta A, B and C.

But if I setup this I get: "Included build '%s' cannot have included builds.".

Expected Behavior

Recursive "includeBuild" would recursively include dependent projects.

Current Behavior

I get "Included build '%s' cannot have included builds.".

Your Environment

Gradle 3.5, Buildship 2.0, Eclipse 3.6



我如何解决/解决此问题?在我的实例中,我有一个包含电子邮件功能(使用JavaMail)的实用程序项目。数据项目和UI项目中需要电子邮件功能。 UI项目还取决于数据项目。

最佳答案

为其他方法添加另一个答案...

每个settings.gradle可以在includeBuild之前添加一个检查,以查看它是否已经在复合文件中。如果它已经在组合中,则它不是includeBuild

有关复合检查的更多信息,请参见here

例如
project2/settings.gradle

boolean inComposite = gradle.parent != null
if (!inComposite) {
includeBuild '../project1'
}
project3/settings.gradle
boolean inComposite = gradle.parent != null
if (!inComposite) {
includeBuild '../project1'
includeBuild '../project2'
}
project4/settings.gradle
boolean inComposite = gradle.parent != null
if (!inComposite) {
includeBuild '../project1'
includeBuild '../project2'
includeBuild '../project3'
}



使用这种方法,您可以在任何需要的地方运行 gradle,并且应该表现出预期的效果(即用本地项目替换依赖项)

关于eclipse - 如何允许/解决嵌套复合Gradle构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43989057/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com