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.)
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 .
In Gradle dependencies are grouped into a named set of dependencies. These groups are called configurations, and we use them to declare the external dependencies of our project.
The dependency tree in a build scan renders the selection reason (conflict resolution) as well as the origin of a dependency if you click on a dependency and select the "Required By" tab. Every Gradle project provides the task dependencyInsight to render the so-called dependency insight report from the command line.
Compile − The dependencies required to compile the production source of the project. Runtime − The dependencies required by the production classes at runtime. By default, it also includes the compile time dependencies. Test Compile − The dependencies required to compile the test source of the project.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With