9

Some times, I don't want to add all of the dependency, so I need to exclude some from dependency, for example :

  compile('com.google.http-client:google-http-client:1.20.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }

I found com.google.http-client source code in github here, however, from the source code I can't find which part belongs to group "org.apache.httpcomponents" and which part belongs to 'httpclient'

I am a beginer on Gradle, so Can anyone explain how do I identify group and module?

(like stackoverflow question here, someone just post exclude group '****',module:'****', but I want to know where is the group and module,so in the future I can solve this qustion by myself.)

Community
  • 1
  • 1
user3239558
  • 1,757
  • 4
  • 18
  • 31

2 Answers2

10

It's not about exclusion of some classes or packages from dependency, rather about exclusion of some transitive dependencies. Group and module are properties for looking up libraries within maven repositories. For your dependency

com.google.http-client:google-http-client:1.20.0

Group is com.google.http-client, module is google-http-client and the version is 1.20.0. And when you add

exclude group: 'org.apache.httpcomponents', module: 'httpclient'

You just exclude sone transitive dependency to be loaded and added to your project by default.

In your exact case, you can take a look at the project's pom-file, which declares project dependencies as follows:

<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>${project.httpclient.version}</version>
</dependency>

Here, group is equals to groupId and module is equals to artifactId. You can read about it here.

If you wish to find out, what transitive dependencies are in your project, you can take a look at the library description page at the repository web page, or just call in command line gradle dependencies to print out all the dependencies of your project, include transitive dependencies.

Stanislav
  • 27,441
  • 9
  • 87
  • 82
1

I tend to use grepcode. So, for your example, you can browse the dependencies of 'com.google.http-client:google-http-client:1.20.0' at http://grepcode.com/snapshot/repo1.maven.org/maven2/com.google.http-client/google-http-client/1.20.0/.

hippocrene
  • 84
  • 1
  • 7