【问题标题】:CircularReferenceException when letting subprojects depend on other subprojects让子项目依赖其他子项目时出现 CircularReferenceException
【发布时间】:2016-02-18 04:28:33
【问题描述】:

在我的项目中,我有 6 个子项目,它们都相互依赖。

subprojects {
    apply plugin: 'java'

    repositories {
        mavenCentral()
    }

    dependencies {
        compile project(":common")
        compile project(":def")
        compile project(":fs")
        compile project(":game")
        compile project(":network")
        compile project(":parser")

        ... remainder omitted
    }

}

在我的主项目 build.gradle 文件中声明这样的依赖项时,我收到循环依赖项错误。

我也尝试过在他们自己的 build.gradle 中声明每个子项目所依赖的依赖项,但只是收到相同的错误。

我有什么遗漏吗?

【问题讨论】:

  • 如果A依赖B,B就不能依赖A。那你做错了,
  • 不能像我在 Maven 模块中那样反过来工作吗? @GabrieleMarriotti
  • 这不是 gradle 问题。你无法实现类似的依赖

标签: gradle build build.gradle


【解决方案1】:

你正试图实现这样的事情:

项目 A:

dependencies {
        compile project(":B)
        compile project(":C")
}

项目 B:

dependencies {
        compile project(":A)
        compile project(":C")
}

项目 C:

dependencies {
        compile project(":B)
        compile project(":A")
}

这是一个CircularReference
如果A依赖B,B就不能依赖A。

你做不到。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2022-10-02
  • 2016-01-13
  • 2016-02-28
  • 2022-01-18
  • 1970-01-01
  • 2020-08-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多