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?
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.
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.
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.
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
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With