# Force a transitive dependency version

**URL:** <https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813>\
**Category:** Help/Discuss\
**Created:** [December 14, 2016, 7:05pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813 "2016-12-14T19:05:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![las2k](https://avatars.discourse-cdn.com/v4/letter/l/e79b87/32.png) [@las2k](https://discuss.gradle.org/u/las2k)\
**Post date:** [December 14, 2016, 7:05pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813/1 "2016-12-14T19:05:07Z")

</div>

I am developing a library which depends on several dependencies. I want to force versions for certain dependencies of my library and i don’t want them to be overridden by the client. How can something like this be implemented?

---

<div class="post-metadata">

**Author:** ![las2k](https://avatars.discourse-cdn.com/v4/letter/l/e79b87/32.png) [@las2k](https://discuss.gradle.org/u/las2k)\
**Post date:** [December 22, 2016, 4:49pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813/2 "2016-12-22T16:49:49Z")

</div>

Is there a solution for this problem?

---

<div class="post-metadata">

**Author:** ![las2k](https://avatars.discourse-cdn.com/v4/letter/l/e79b87/32.png) [@las2k](https://discuss.gradle.org/u/las2k)\
**Post date:** [January 13, 2017, 7:02pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813/3 "2017-01-13T19:02:17Z")

</div>

Is there any solution for this other than writing a plugin and asking clients to include the plugin?

---

<div class="post-metadata">

**Author:** ![las2k](https://avatars.discourse-cdn.com/v4/letter/l/e79b87/32.png) [@las2k](https://discuss.gradle.org/u/las2k)\
**Post date:** [January 25, 2017, 8:17pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813/4 "2017-01-25T20:17:51Z")

</div>

Anyone has any solution for this please?

---

<div class="post-metadata">

**Author:** ![Lance](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance/32/787_2.png) [@Lance](https://discuss.gradle.org/u/Lance)\
**Post date:** [January 25, 2017, 8:40pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813/5 "2017-01-25T20:40:53Z")

</div>

> I want to force versions for certain dependencies of my library

That can be done in a [resolutionStrategy](https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html)

> i don’t want them to be overridden by the client

I’m not sure what you are asking here. Are you asking that gradle projects depending on your library should be denied the opportunity to force their own version? That’s a but hypocritical of you given your first request. Gradle won’t somehow disable this feature for your clients

---

<div class="post-metadata">

**Author:** ![las2k](https://avatars.discourse-cdn.com/v4/letter/l/e79b87/32.png) [@las2k](https://discuss.gradle.org/u/las2k)\
**Post date:** [January 25, 2017, 8:44pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813/6 "2017-01-25T20:44:18Z")

</div>

I understand forcing version using resolution strategy to avoid my transitive dependencies bringing higher version.

I am looking for ways i can do the same if my library is added as a dependency by a client where the client application and my library have a common dependency but i want to dictate the version. I understand that spring-boot plugin has implemented similar feature and i am looking for a way other than a custom plugin.

---

<div class="post-metadata">

**Author:** ![Lance](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance/32/787_2.png) [@Lance](https://discuss.gradle.org/u/Lance)\
**Post date:** [January 25, 2017, 9:03pm UTC](https://discuss.gradle.org/t/force-a-transitive-dependency-version/20813/7 "2017-01-25T21:03:01Z")

</div>

As I said it seems a bit hypocritical to benefit from this feature yourself but want to deny the same feature to your clients. And no, gradle won’t disable this feature for your clients.

Perhaps, instead, you could repackage a dependency using [shadow](https://github.com/johnrengelman/shadow/blob/master/README.md). This way a client could use a different version without affecting your library’s functionality. This is how libraries like hibernate and spring bring in the [asm](http://asm.ow2.org) dependency
