Gradle dependency conflict resolution debugging

I am having multiple version of dependency of spring and gradle do weird conflict resolution.

|    |    +---
|    |    |    +--- org.springframework:spring-context:3.1.4.RELEASE -> 4.0.0.M3 (*)

Basically it boost version from 3.1.4.RELEASE to 4.0.0.M3 and I cannot understand why. There are no reference for spring 4.0.0.M3 whatsoever. It is being pulled transitively, but no top artifact uses latest spring. I checked maven repositories and they have newest version of spring, so I cannot claim that gradle blindly takes last one version.

How can I troubleshoot it? I enabled debug, but there is no explanation why.
That’s first appearance for version 4.0.0.

10:41:39.499 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.IvyXmlModuleDescriptorParser] post 1.3 ivy file: using exact as default matcher
10:41:39.501 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'org.springframework:spring-tx:4.0.0.M3' in 'maven2'

If there are conflicting versions of the same dependency (e.g., spring-context in your case), Gradle will choose the latest version by default. spring-data-redis depends on 3.1.4.RELEASE of spring-context, but spring-tx depends on 4.0.0.M3 of spring-context. Gradle will choose 4.0.0.M3.

You can see this if you use gradle dependencyInsight --dependency spring-context --configuration <your configuration name, probably compile?> Dependency insight shows you where a particular dependency came from.

You can read more here:

You can enforce a particular version for spring-context by forcing it.

1 Like