I'm getting a wrong version of a dependency

(Michał Huniewicz) #1

I’m getting a different (newer) version of an artifact in my output war file than the one I asked for:

project.ext.springVersion = ‘3.1.2.RELEASE’

dependencies {

compile group: ‘org.springframework’, name: ‘spring-core’, version: springVersion

compile group: ‘org.springframework’, name: ‘spring-context’, version: springVersion

What I’m getting though is spring-context 3.2.0.M2 (and other Spring artifacts). Here’s a fragment of gradle dependency:

compile - Classpath for compiling the main sources. ±-- org.springframework:spring-webmvc:3.1.2.RELEASE [default] |

±-- org.springframework:spring-asm:3.1.2.RELEASE [compile,master,runtime] |

±-- org.springframework:spring-context-support:3.1.2.RELEASE [compile,master,runtime] |


±-- org.springframework:spring-context:3.2.0.M2 [compile,master,runtime] […] — org.springframework:spring-core:3.2.0.M2 [default] () — org.springframework:spring-context:3.2.0.M2 [default] ()

Why? How can I fix this?

(Michał Huniewicz) #2

Well, this helps, but is this really the way to do it?

configurations.all {

resolutionStrategy {


force group: ‘org.springframework’, name: ‘spring-core’, version: springVersion

} }

(Andrew Oberstar) #3

Do you have another dependency that transitively depends on Spring 3.2.0.M2?

(Michał Huniewicz) #4

Yes, the it’s pulled in by spring data mongodb.

(Peter Niederwieser) #5

It’s one way to do it, although you don’t necessarily need the ‘failOnVersionConflict()’. For dependencies that you declare yourself, a simpler solution is ‘dependencies { compile “org.springframework:spring-core:$springVersion” { force = true } }’.

(Michał Huniewicz) #6

Hi Peter. What’s the proper way then?

(Peter Niederwieser) #7

I already showed another way. Did you see my edit?

(Michał Huniewicz) #8

I didn’t, now I do, thanks. Why shouldn’t this be the default behaviour?

(Peter Niederwieser) #9

I think it should, but not everyone shares this opinion. Besides, it’s probably too late to change the default.

(Michał Huniewicz) #10

Okay, thanks.

(Michał Huniewicz) #11

Peter, if you actually Reply below my question (with the force thing), I will be able to mark the question as answered.

(Peter Niederwieser) #12

Unfortunately, only moderators can mark topics as answered. I’ll do that now.