16

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?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Mastering_the_Object
  • 1,023
  • 1
  • 7
  • 13
  • 3
    I found a Jira on this that has not been addressed yet, but there seems to be a work around as follows: add additional parens around project as follows compile (project(':subproject')) { transitive = false } - I am using this and it is working for me - not intuitive but effective – Mastering_the_Object Dec 17 '12 at 22:47
  • This comment should be marked answer. The unfortunate aspect of it is that once you exclude all that projects deps, if you happen to include one of that set (because you only need a subset of the jars in that list) gradle wont let you. So for crazy projects have fun excluding dep by dep just to do something simple. – Core Dec 12 '14 at 17:40

1 Answers1

30

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
    }
} 
Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259