Steve Ebersole wrote:
On Fri, 2009-10-09 at 20:48 -0600, [email protected] wrote:

Hm. The compile configuration is already non-transitive, what you did should 
have worked (and I've had it work just for me in the past as well):
Ok, just a mis-guess then coming from Maven that compile would be transitive.  
Its one or the other, I just guessed wrong.  Section 18.4 describes that.

But regardless, I need both sets : compile-time deps that are transitive
as well as compile-time deps that are non-transitive.  So I cannot
simply turn on transitivity of the compile configuration here like shown
in the docs.  So what is the best way to do that?  I understand I could
in fact specify transitivity on each dependency, but I prefer the
grouping approach (here are the set of transitive compile-time
dependencies) from a readability perspective.  Obviously if such an
approach (split config, etc) causes more difficulty elsewhere, that
could sawy me too :)


Ideally, you would be able to do something like this:

configurations {
   provided {
       transitive = true
   }
   compile {
       extendsFrom provided
   }
}

dependencies {
   provided 'some-transitive-dependency'
   compile 'some-non-transitive-dependency'
}

so that any dependency added to compile is not transitive, and any dependency added to provided is transitive.

Unfortunately, the 'transitive' flag from compile wins when it is resolved, so every dependency will be non transitive.

We can add the following hack somewhere in the build file to get the behaviour we need:

afterEvaluate {
   configurations.compile.transitive = true
   configurations.compile.dependencies.each { it.transitive = false }
   configurations.provided.dependencies.each { it.transitive = true }
}


I think the current behaviour of the transitive flag could be improved. Perhaps we should change things so that the configuration's transitive flag simply works as the default value for the transitive flag of the dependencies in the configuration.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org

Reply via email to