1
在我的gradle構建腳本中,我強制3.1.0發佈庫用於Spring框架。我發現這個解決方案策略的變化適用於編譯,測試編譯,testRuntime,但不適用於從'gradle dependencies'輸出中可見的運行時。gradle resolutionStrategy不更新運行時
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:彈簧核心: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任務中包含編譯依賴關係?但是這可能會在存檔中創建重複的庫。