gradle中找不到公寓包含多项目的子项目

时间:2019-03-06 10:15:23

标签: java gradle

我陷入了gradle中的传递依赖注入。我有以下结构:

A/
  build.gradle.kts
  settings.gradle.kts
B/
  build.gradle.kts
  settings.gradle.kts
  C/
    build.gradle.kts
  • A取决于项目B。
  • A包含B
  • B包括C
  • A和B在不同的存储库中,因此它们没有共同的根。

构建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'

1 个答案:

答案 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")

结果

gradle -q projects