Frustrated by trying to exclude a dependency

I’m really frustrated being unable to exclude Android httpclient. Even though the dependency graph states that:

+--- com.google.api-client:google-api-client-android:1.20.0
|    +--- com.google.api-client:google-api-client:1.20.0
|    |    +--- com.google.oauth-client:google-oauth-client:1.20.0
|    |    |    +--- com.google.http-client:google-http-client:1.20.0
|    |    |    |    +--- com.google.code.findbugs:jsr305:1.3.9
|    |    |    |    \--- org.apache.httpcomponents:httpclient:4.0.1
|    |    |    |         +--- org.apache.httpcomponents:httpcore:4.0.1
|    |    |    |         +--- commons-logging:commons-logging:1.1.1
|    |    |    |         \--- commons-codec:commons-codec:1.3
|    |    |    \--- com.google.code.findbugs:jsr305:1.3.9
|    |    +--- com.google.http-client:google-http-client-jackson2:1.20.0
|    |    |    +--- com.google.http-client:google-http-client:1.20.0 (*)
|    |    |    \--- com.fasterxml.jackson.core:jackson-core:2.1.3
|    |    \--- com.google.guava:guava-jdk5:13.0
|    \--- com.google.http-client:google-http-client-android:1.20.0
|         \--- com.google.http-client:google-http-client:1.20.0 (*)

It’s still there despite my attempt to exclude it from everywhere:

compile('com.google.api-client:google-api-client-android:1.20.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.http-client:google-http-client-gson:1.20.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.android.gms:play-services-identity:10.0.1') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-drive:v2-rev176-1.20.0') {
    exclude group: 'org.apache.httpcomponents'
}

This is really frustrating. I could employ this:

configurations {
    compile.exclude group: 'org.apache.httpcomponents', module: "httpclient"
}

but I feel I would just use it out of desperation, since I would really like to be able to pinpoint where the dependency is coming from, and exclude it there.

Using excludes on individual dependencies is almost never correct as they could come from many other places. Excluding it at the configuration level is much cleaner.

Maybe my frustration stems from me being used to the Maven way. That is, exclude dependencies on individual dependencies instead on one place. Maybe the Gradle approach makes more sense… have to think about that :slight_smile: thanks!