【发布时间】:2021-07-28 04:52:57
【问题描述】:
我正在尝试使用 OSGI 来允许我使用两个不同版本的传递依赖项。计划是一个版本(较新的版本)将隐藏在 OSGI 包中,另一个将像往常一样位于运行时类路径中。
我已经使用 Gradle(使用 Groovy DSL)构建了 bundle jar,但问题是它相关的运行时依赖项是错误的 - 它带来了更新的版本,它应该隐藏在 bundle 中。当我这样做时,这仍然是正确的,在 build.gradle 文件中:
compileOnly deps.diffx
runtimeOnly(deps.diffx) {
exclude group: 'com.propensive', module: 'magnolia_' + versions.scala_v
}
如果我使用 Gradle dependencies 任务检查依赖关系,它显示 magnolia 已按预期从 runtimeOnly 配置中排除 - 但 没有 从 runtimeClasspath 配置中排除。
如果我随后使用./gradlew dependencyInsight --dependency magnolia_2.12 --configuration runtime 来尝试找出此依赖项的来源,它会告诉我新版本来自runtimeClasspath,具体取决于diffx,这是通过冲突解决选择的。好吧,谢谢-我已经知道了。问题是,为什么我的排除不适用于派生配置?
基本上我想做与this question相反的事情。
我也尝试了约束版本,但它们表现出同样的问题:
compileOnly deps.diffx
runtimeOnly(deps.diffx) {
constraints {
implementation('com.propensive:magnolia_' + versions.scala_v + ':0.10.0') {
because 'this version is required by our other dependencies'
}
}
}
【问题讨论】:
标签: gradle osgi dependency-management bnd