我在 IntelijIdea 中有这个项目结构
--TestProject
----TestLib
------CoreModule
settings.gradle.kts(:TestLib)
rootProject.name = "TestLib"
include("CoreModule")
build.gradle.kts(:TestLib)
dependencies {
implementation(project("CoreModule"))
}
settings.gradle.kts(测试项目)
rootProject.name = "TestProject"
include("TestLib")
为什么在 gradle 构建期间我会得到
在项目“:TestLib”中找不到路径为“CoreModule”的项目
如果将 settings.gradle.kts(TestProject) 更改为
rootProject.name = "TestProject"
include("TestLib")
include("TestLib:CoreModule")
然后构建通过,但我不明白为什么在根项目中我需要指示子模块的所有依赖项,理论上模块本身应该拉起自己的依赖项
通过创建
settings.gradle(.kts)文件夹,您可以告诉 Gradle 这是一个项目文件夹,并确定该项目中有哪些模块。这里没有说谁依赖谁,而只是说谁在哪里。
接下来,
build.gradle(.kts)为每个模块指定一个依赖树。