Gradle不包含可选的依赖项 [英] Gradle Does Not Include Optional Dependency

查看:786
本文介绍了Gradle不包含可选的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,它具有 apache-compress 库作为编译时间依赖项。这个库似乎使用Maven,并有一个POM文件,其依赖项设置为可选。以下是POM文件的相关部分:

 <依赖关系> 
< groupId> org.tukaani< / groupId>
< artifactId> xz< / artifactId>
< version> 1.5< / version>
<可选> true< /可选>
< /依赖关系>

Gradle似乎没有将这个库包含到我的项目中,我猜这是因为可选属性。有没有什么方法可以告诉Gradle在不明确包含xz库的情况下包含这个依赖项?



这是我的Gradle依赖声明: compile group: 'org.apache.commons',name:'commons-compress',version:'1.8.1'

解决方案 div>

传递依赖关系解析不考虑可选依赖关系,必要时必须明确添加。 (Maven也一样。)

I have a project which has the apache-compress library as a compile time dependency. This library appears to use Maven and has a POM file with a dependency set up as "optional". Here is the relevant section of the POM file:

<dependency>
  <groupId>org.tukaani</groupId>
  <artifactId>xz</artifactId>
  <version>1.5</version>
  <optional>true</optional>
</dependency>

Gradle does not seem to include this library in to my project, I'm guessing it is because of the "optional" attribute. Is there some way to tell Gradle to include this dependency without explicitly including the xz library myself?

Here is my Gradle dependency declaration: compile group: 'org.apache.commons', name:'commons-compress', version:'1.8.1'

解决方案

Optional dependencies aren't considered for transitive dependency resolution, and have to be added explicitly if necessary. (It's the same in Maven.)

这篇关于Gradle不包含可选的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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