简体   繁体   中英

gradle exclude transient dependency from project

In my build.gradle I have the following snipped:

dependencies {
    compile project(':utils')
    compile (project(':cache')) {
        // excludings because of dropwizard conflicts
        exclude group: 'org.glassfish.jersey.core'
        exclude group: 'javax.ws.rs'
        exclude group: 'com.codahale.metrics'
    }

but in fact the artifacts are not excluded I still end up with different jersey and metrics in my classpath. Ony if I put this in my cache/build.gradle it will compile and run.

configurations {
    all*.exclude group: 'com.codahale.metrics'
    all*.exclude group: 'org.glassfish.jersey.core'
} 

But then my cache project is broken because of missing dependencies which is not what I wanted.

I've had issues with this in the past, what worked was when I included module: explicitly along with the group. like so:

exclude group: 'commons-math3', module: 'commons-math3'

If you use configurations to exclude, you don't have to do it on all*, you can do it on just local project compile as :

compile.exclude group: 'commons-math3', module: 'commons-math3'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM