我陷入了gradle中的传递依赖注入。我有以下结构:
A/
build.gradle.kts
settings.gradle.kts
B/
build.gradle.kts
settings.gradle.kts
C/
build.gradle.kts
构建A时,出现以下错误:
* Where:
Build file '/.../B/build.gradle.kts' line: 7
* What went wrong:
Project with path 'C' could not be found in project ':B'.
我应该在A/settings.gradle.kts
中放入什么使其起作用?
所有文件都可以重现我的问题:
A / build.gradle.kts
plugins { `java-library` }
dependencies { api(project("B")) }
A / settings.gradle.kts
rootProject.name = "A"
includeFlat("B")
B / build.gradle.kts
plugins { `java-library` }
dependencies { api(project("C")) }
B / settings.gradle.kts
rootProject.name = "C"
include("C")
B / C / build.gradle.kts
plugins { `java-library` }
dependencies { }
这是B中列表项目的输出
B/# gradle -q projects
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'B'
\--- Project ':C'
答案 0 :(得分:1)
您可以尝试:
A / settings.gradle.kts
rootProject.name = "A"
include("B", "B:C")
project(":B").projectDir = File(settingsDir, "../B")
project(":B:C").projectDir = File(settingsDir, "../B/C")
结果