gpt4 book ai didi

gradle - 为什么一个项目依赖被另一个已经存在的依赖替换

转载 作者:行者123 更新时间:2023-12-03 04:21:20 27 4
gpt4 key购买 nike

我的构建失败,因为某些依赖项没有得到满足。当我运行 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

总线/build.gradle
subprojects {
apply plugin: 'java'
apply plugin: 'maven'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}
}

总线/api/build.gradle
group 'kic'
version '1.0-SNAPSHOT'
archivesBaseName = 'kic-bus-api'

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

状态/build.gradle
subprojects {
apply plugin: 'java'
apply plugin: 'maven'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}
}

状态/api/build.gradle
group 'kic'
version '1.0-SNAPSHOT'
archivesBaseName = 'kic-state-api'

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

最佳答案

我看起来不再尊重 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"

关于gradle - 为什么一个项目依赖被另一个已经存在的依赖替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50432229/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com