How do you exclude a transitive project dependency

2020-06-08 13:54发布

问题:

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?

回答1:

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