Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you exclude a transitive project dependency in gradle

given

dependencies {
   compile project(':subproject') {
        transitive = false
   }
}

This does not work properly in gradle 1.3. (i.e. all dependencies are included from the subproject)

Is this a bug or is there a different syntax for excluding project dependencies?

like image 427
Mastering_the_Object Avatar asked Dec 17 '12 22:12

Mastering_the_Object


People also ask

How do you avoid transitive dependencies 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 I exclude an entire project dependency?

Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.

How do you change transitive dependency on Gradle?

To override the version of a transitive dependency in Gradle, exclude it from the declared dependency that pulls it in, and then explicitly declare the version that you prefer to use in your build.


1 Answers

The shown syntax will add a new (so-called dynamic) transitive property to the Project object, which, unless used somewhere else, won't have any effect. You'll get a warning that dynamic properties have been deprecated, which is a sign of a potential mistake in the build script, and will fail hard in Gradle 2.0.

The correct syntax is (as you already indicated):

dependencies {
    compile(project(':subproject')) {
        transitive = false
    }
} 
like image 174
Peter Niederwieser Avatar answered Nov 04 '22 10:11

Peter Niederwieser