Вопрос

In my gradle build script, I forced 3.1.0 release libraries for spring framework. I see that this resolution strategy change is applied to compile, testCompile, testRuntime but not to runtime as visible from 'gradle dependencies' output.

allprojects {
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                if ( details.requested.group == 'org.springframework' ) { 
                    details.useVersion = '3.1.0.RELEASE'
                }
            }
        }
    }

gradle dependencies output:

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.

As you can compile dependencies got over written with 3.1.0.RELEASE but runtime did not. As a result when I distribute a zip for my project jar, I see 3.0.0. version spring libraries.

Is this a problem with my override or resolution strategy does not impact runtime libs? Do I need to include compile dependencies in distZip task? But this might create duplicate libs in the archive.

Это было полезно?

Решение

found out the cause. resolutionStrategy code method was at the bottom of the build script. Once I moved it above all sub projects related build code, it reflected runtime dependencies too.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top