Loading...

Tuesday, October 23, 2012

Gradle Goodness: Exclude Transitive Dependency from All Configurations

We can exclude transitive dependencies easily from specific configurations. To exclude them from all configurations we can use Groovy's spread-dot operator and invoke the exclude() method on each configuration. We can only define the group, module or both as arguments for the exclude() method.

The following part of a build file shows how we can exclude a dependency from all configurations:

...
configurations {
    all*.exclude group: 'xml-apis', module: 'xmlParserAPIs'
}

// Equivalent to:
configurations {
    all.collect { configuration ->
        configuration.exclude group: 'xml-apis', module: 'xmlParserAPIs'
    }
}
...

Written with Gradle 1.2

1 comments:

Unknown said...

I wonder whether you truly understand what transitive dependencies are? All I can see is how you exclude a very specific group of dependencies. This has nothing to do with transitivity.

Post a Comment