gpt4 book ai didi

gradle - 如何在Gradle中创建一个多项目?

转载 作者:行者123 更新时间:2023-12-03 05:44:00 25 4
gpt4 key购买 nike

我想将我的第一个项目“Component1-1-1”包含在我的第二个项目“Component1-1”中,我在我的setting.gradle文件中添加了以下语法:

include ':Component1-1-1'
project(':Component1-1-1').projectDir = new File(settingsDir, '../Component1-1-1')

然后我添加到我的build.gradle文件中:
earlib project(':Component1-1-1')

它工作正常,但是我的问题是我不了解“:”的用处,我试图将“:”移到settings.gradle中:
include 'Component1-1-1'
project(':Component1-1-1').projectDir = new File(settingsDir, '../Component1-1-1')

在build.gradle中:
earlib project(':Component1-1-1')

而且一切正常,我不知道为什么...

最佳答案

project()函数内的gradle中引用项目时,需要限定项目名称,分隔符为':'。与linux中的'/'相同。

但是,当您使用include()定义一个新项目时,您只需传递该项目的相对文件路径,所以不能使用':'。

Gradle只是在include ':Component1-1-1'中丢弃冒号。
请参见https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/java/org/gradle/initialization/DefaultSettings.java中的包含定义

以及实际上应称为“removeLeadingColon”的方法“removeTrailingColon”。

关于gradle - 如何在Gradle中创建一个多项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51044578/

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