【问题标题】:Why is one project dependency replaced by another already existing one为什么一个项目依赖被另一个已经存在的依赖替换
【发布时间】:2018-05-20 15:31:43
【问题描述】:

我的构建失败,因为某些依赖项没有得到满足。当我运行 gradle 依赖项任务时,我得到了一些令人惊讶的东西。完全不同的项目 project :state:api 和项目 :bus:api 没有被区别对待,而是被视为相同。 Whis 似乎是我只将总线 api 的类放到我的类路径中的原因。但为什么?我正在使用 gradle 4.7,我也在不同的地方尝试了 settings.gradle 和 rootProject.name,没有任何区别。

./gradlew server:dependencies --configuration compile | grep project
+--- project :bus:api
+--- project :bus:simple-list-bus
|    +--- project :bus:api
+--- project :state:api -> project :bus:api
+--- project :state:simple-state
|    +--- project :state:api -> project :bus:api
+--- project :utils:common

bus/build.gradle

subprojects {
    apply plugin: 'java'
    apply plugin: 'maven'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    repositories {
        mavenCentral()
    }
}

bus/api/build.gradle

group 'kic'
version '1.0-SNAPSHOT'
archivesBaseName = 'kic-bus-api'

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

state/build.gradle

subprojects {
    apply plugin: 'java'
    apply plugin: 'maven'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    repositories {
        mavenCentral()
    }
}

state/api/build.gradle

group 'kic'
version '1.0-SNAPSHOT'
archivesBaseName = 'kic-state-api'

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

【问题讨论】:

    标签: gradle


    【解决方案1】:

    我似乎不再尊重 settings.gradle 中的 rootProject.name。看起来现在只有一个(顶级根)settings.gradle 受尊重/允许。这意味着必须在最顶层的根 settings.gradle 中指定子模块名称,如下所示:

    include ':bus'
    include ':bus:api'
    include ':bus:simple-list-bus'
    include ':state'
    include ':state:api'
    include ':state:simple-state'
    
    project(":state:api").name = "kic-state-api"
    project(":state:simple-state").name = "kic-state-simple"
    project(":bus:api").name = "kic-bus-api"
    project(":bus:simple-list-bus").name = "kic-bus-simple"
    

    【讨论】:

      猜你喜欢
      • 2019-01-24
      • 2021-09-30
      • 2018-06-26
      • 2020-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多