Please explain why an exclude doesn't work

I can’t exclude a guava module in a build.gradle file using “exclude”. This seems like a basic function, and I have used exclude elsewhere successfully, which is why I’m baffled by this simple case.

With this dependency block:

dependencies {
        ...
        compile(group: 'com.google.api-client', name: 'google-api-client', version: '1.19.0') {
            exclude(group: 'com.google.guava', module: 'guava-jdk5') // !!! Doesn't work!!!
           ...
        }
    ...
    }

I get the dependency tree below. Note that guava-jdk5 is not excluded.

±-- com.google.api-client:google-api-client:1.19.0

|

±-- com.google.oauth-client:google-oauth-client:1.19.0

|

|

±-- com.google.http-client:google-http-client:1.19.0

|

|

|

|

|

— com.google.code.findbugs:jsr305:1.3.9

|

|

— com.google.guava:guava-jdk5:13.0

Notice that the last line still includes the guava module, it has not been excluded. Why? How to exclude it?

This works for me. There’s 2 things I can think of: 1) You’re excluding from the configuration ‘compile’: perhaps the dependency tree you’re displaying is for a different configuration? Try running ‘gradle depedencies --configuration compile’ 2) You’ve got the ‘google-api-client’ dependency declared twice, once without the exclude.

Thanks Daz, you were right. I had the ‘google-api-client’ declared in another part of the project and didn’t realize it. The command you suggested help, and also using dependencyInsight on the guava module.

Btw, is there a key somewhere on the symbols used for the dependency tree? The difference between a “+” and a “” is not entirely clear.

Thanks!

That’s just how the Gradle CLI renders a tree. a ‘+’ indicates a new branch, the ‘’ is the last leaf of a branch.

Got it, thanks