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?

2
  • 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 Commented Dec 17, 2012 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. Commented Dec 12, 2014 at 17:40

1 Answer 1

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 } } 
Sign up to request clarification or add additional context in comments.

2 Comments

No such property: transitive for class: org.gradle.api.internal.project.DefaultProject_Decorated
syntax has fixed, but the dependency also transitive to parent project.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.