Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle, How To Disable All Transitive Dependencies

Many of my jars have conflicting transitive dependencies (multiple spring versions). I would like to avoid inherited version conflicts by managing all of my dependencies explicitly, is it possible to disable all transitive dependencies in Gradle?

I know I can add transitive = false to each of my dependencies, but I am hoping there is a simpler way.

compile(group: 'org.springframework', name: 'spring', version: '2.5.2') {     transitive = false } 
like image 978
Mike Rylander Avatar asked Jul 23 '13 16:07

Mike Rylander


People also ask

How do I get rid of transitive dependency in Gradle?

When you specify a dependency in your build script, you can provide an exclude rule at the same time telling Gradle not to pull in the specified transitive dependency. For example, say we have a Gradle project that depends on Google's Guava library, or more specifically com.

How do you remove a transitive dependency?

If a transitive dependency exists, we remove the transitively dependent attribute(s) from the relation by placing the attribute(s) in a new relation along with a copy of the determinant.

Does Gradle support transitive dependencies?

Gradle automatically resolves those additional modules, so called transitive dependencies. If needed, you can customize the behavior the handling of transitive dependencies to your project's requirements. Projects with tens or hundreds of declared dependencies can easily suffer from dependency hell.


1 Answers

I ended up using:

configurations.all {     transitive = false } 
like image 187
Mike Rylander Avatar answered Sep 27 '22 18:09

Mike Rylander