# I'm getting a wrong version of a dependency

**URL:** <https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417>\
**Category:** Old Forum Archive\
**Created:** [November 2, 2012, 3:09pm UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417 "2012-11-02T15:09:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Huniewicz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/michal_huniewicz/32/1174_2.png) [@Michal\_Huniewicz](https://discuss.gradle.org/u/Michal_Huniewicz)\
**Post date:** [November 2, 2012, 3:09pm UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/1 "2012-11-02T15:09:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Michal\_Huniewicz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/michal_huniewicz/32/1174_2.png) [@Michal\_Huniewicz](https://discuss.gradle.org/u/Michal_Huniewicz)\
**Post date:** [November 2, 2012, 9:45pm UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/2 "2012-11-02T21:45:00Z")

</div>

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

configurations.all {

resolutionStrategy {

failOnVersionConflict()

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

} }

---

<div class="post-metadata">

**Author:** ![ajoberstar](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ajoberstar/32/127_2.png) [@ajoberstar](https://discuss.gradle.org/u/ajoberstar)\
**Post date:** [November 2, 2012, 11:24pm UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/3 "2012-11-02T23:24:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michal\_Huniewicz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/michal_huniewicz/32/1174_2.png) [@Michal\_Huniewicz](https://discuss.gradle.org/u/Michal_Huniewicz)\
**Post date:** [November 2, 2012, 11:33pm UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/4 "2012-11-02T23:33:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 3, 2012, 12:03am UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/5 "2012-11-03T00:03:00Z")

</div>

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 } }’.

---

<div class="post-metadata">

**Author:** ![Michal\_Huniewicz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/michal_huniewicz/32/1174_2.png) [@Michal\_Huniewicz](https://discuss.gradle.org/u/Michal_Huniewicz)\
**Post date:** [November 3, 2012, 12:12am UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/6 "2012-11-03T00:12:00Z")

</div>

Hi Peter. What’s the proper way then?

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 3, 2012, 12:16am UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/7 "2012-11-03T00:16:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michal\_Huniewicz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/michal_huniewicz/32/1174_2.png) [@Michal\_Huniewicz](https://discuss.gradle.org/u/Michal_Huniewicz)\
**Post date:** [November 3, 2012, 12:20am UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/8 "2012-11-03T00:20:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 3, 2012, 12:48am UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/9 "2012-11-03T00:48:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michal\_Huniewicz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/michal_huniewicz/32/1174_2.png) [@Michal\_Huniewicz](https://discuss.gradle.org/u/Michal_Huniewicz)\
**Post date:** [November 3, 2012, 1:05am UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/10 "2012-11-03T01:05:00Z")

</div>

Okay, thanks.

---

<div class="post-metadata">

**Author:** ![Michal\_Huniewicz](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/michal_huniewicz/32/1174_2.png) [@Michal\_Huniewicz](https://discuss.gradle.org/u/Michal_Huniewicz)\
**Post date:** [November 3, 2012, 10:23am UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/11 "2012-11-03T10:23:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [November 3, 2012, 6:47pm UTC](https://discuss.gradle.org/t/im-getting-a-wrong-version-of-a-dependency/7417/12 "2012-11-03T18:47:00Z")

</div>

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