【发布时间】:2014-02-27 18:01:49
【问题描述】:
在我的 gradle 构建脚本中,我为 spring 框架强制发布了 3.1.0 库。我看到这种解析策略更改适用于 compile、testCompile、testRuntime,但不适用于从“gradle dependencies”输出中看到的运行时。
allprojects {
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if ( details.requested.group == 'org.springframework' ) {
details.useVersion = '3.1.0.RELEASE'
}
}
}
}
gradle 依赖输出:
compile - Compile classpath for source set 'main'.
+--- org.codehaus.groovy:groovy-all:2.1.1
+--- com.company.mod1:module1:2.21.2
| +---org.springframework:spring-core:3.0.0.RC1 -> 3.1.0.RELEASE
| | +--- org.springframework:spring-asm:3.1.0.RELEASE
| | \--- commons-logging:commons-logging:1.1.1
| +--- org.springframework:spring-context:3.0.0.RC1 -> 3.1.0.RELEASE
| | +--- org.springframework:spring-aop:3.1.0.RELEASE
| | | +--- aopalliance:uopalliance:1.0
| | | +--- org.springframework:spring-asm:3.1.0.RELEASE
runtime - Runtime classpath for source set 'main'.
+--- org.codehaus.groovy:groovy-all:2.1.1
+--- com.company.mod1:module1:2.21.2
| +--- org.springframework:spring-core:3.0.0.RC1
| | +--- org.springframework:spring-asm:3.0.0.RC1
| | \--- commons-logging:commons-logging:1.1.1
| +--- org.springframework:spring-context:3.0.0.RC1
| | +--- aopalliance:aopalliance:1.0
| | +--- org.springframework:spring-asm:3.0.0.RC1
| | +--- org.springframework:spring-aop:3.0.0.RC1
| | | +--- aopalliance:aopalliance:1.0
| | | +--- org.springframework:spring-asm:3.0.
你可以编译依赖被 3.1.0.RELEASE 覆盖但运行时没有。结果,当我为我的项目 jar 分发 zip 时,我看到了 3.0.0。版本弹簧库。
这是我的覆盖或解决策略不影响运行时库的问题吗? 我需要在 distZip 任务中包含编译依赖项吗?但这可能会在存档中创建重复的库。
【问题讨论】:
标签: gradle build.gradle