Project dependency picks up a lower version

not-a-bug

(Raviteja) #1

The project seems to pickup an older version of commons-beanutils instead of the new one. I am unsure of what went wrong after upgrading the version number of commons-beantuils.

Current configuration
root\build.gradle

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
    }
}

apply plugin: 'spring-boot'

allprojects {
    apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'project-report'
}

repositories {
        mavenLocal()
        mavenCentral()
    }

dependencies {
    compile project(":child")
}

root\child\build.gradle

dependencies {
    compile 'commons-beanutils:commons-beanutils:1.9.3'
}

root/build/dependencies.txt

\--- project :child
     \--- commons-beanutils:commons-beanutils:1.9.3 -> 1.9.2
          +--- commons-logging:commons-logging:1.1.1 -> 1.2
          \--- commons-collections:commons-collections:3.2.1 -> 3.2.2

root/child/dependencies.txt

default - Configuration for default artifacts.
\--- commons-beanutils:commons-beanutils:1.9.3
     +--- commons-logging:commons-logging:1.2
     \--- commons-collections:commons-collections:3.2.2

runtime - Runtime dependencies for source set 'main'.
\--- commons-beanutils:commons-beanutils:1.9.3
     +--- commons-logging:commons-logging:1.2
     \--- commons-collections:commons-collections:3.2.2

Gradle Version: 3.1
Operating System and JVM version: Windows 2008 R2 Enterprise, Oracle Java 1.8.0_92-b14
Is this a regression? If yes, which version of Gradle do you know it last worked for? Unsure

Older configuration:
root\build.gradle

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
    }
}

apply plugin: 'spring-boot'

allprojects {
    apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'project-report'
}

repositories {
        mavenLocal()
        mavenCentral()
    }

dependencies {
    compile project(":child")
}

root\child\build.gradle

dependencies {
    compile 'commons-beanutils:commons-beanutils:1.9.2'
}

(Raviteja) #2

Gradle is working in this weird way all the way back to 2.1


(Raviteja) #3

Found the culprit, it’s the spring boot plugin

Spring boot plugin has a global dependencyManagement block which had overridden it to commons-beanutils:commons-beanutils:1.9.2 instead of 1.9.3. Shouldn’t 1.9.3 take precedence?


(Eric Wendelin) #4

I don’t know exactly why the Spring Boot Plugin would declare this, but I would guess that perhaps something in commons-beanutils:1.9.3 breaks some functionality in the plugin.

If semantic versioning is adhered to, then yes 1.9.3 should take precedence.


(Jendrik Johannes) #5

To clarify:

Without further configuration Gradle would do what you expect and resolve to the highest version.

However, as you already suspected, Spring Gradle plugins do configure the dependency resolution by providing their own dependency management plugin:
https://github.com/spring-gradle-plugins/dependency-management-plugin.
Using the spring boot plugin, you need to use that, but you can reconfigure dependencies there (e.g., if you need commons-beanutils:1.9.3 in your project). See the plugin’s documentation linked above.


(Raviteja) #6

Thank you @jendrik.

FYI, The fix for this problem was adding the below block:

dependencyManagement {
    dependencies {
        dependency 'commons-beanutils:commons-beanutils:1.9.3'
    }
}