Gradle编译:如何从依赖项中识别组和模块? [英] Gradle Compile: How to identify group and module from dependency?

查看:201
本文介绍了Gradle编译:如何从依赖项中识别组和模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候,我不想添加所有依赖项,因此我需要从依赖项中排除某些依赖项,例如:

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'
    }

我在github 此处中找到了com.google.http-client源代码. >,但是,从源代码中,我找不到属于" org.apache.httpcomponents "组的哪个部分以及属于" 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'

我是Gradle的初学者,所以谁能解释我如何识别模块?

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

(例如stackoverflow问题此处,有人刚刚发布了排除组'****',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.)

推荐答案

这与从依赖项中排除某些类或程序包无关,而与排除某些传递性依赖项有关.组和模块是用于在maven存储库中查找库的属性.为了您的依赖

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

组为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>

在这里,group等于groupIdmodule等于artifactId.您可以在此处进行阅读.

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.

这篇关于Gradle编译:如何从依赖项中识别组和模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆