简体   繁体   English

Gradle不包含可选的依赖项

[英]Gradle Does Not Include Optional Dependency

I have a project which has the apache-compress library as a compile time dependency. 我有一个项目,它将apache-compress库作为编译时依赖项。 This library appears to use Maven and has a POM file with a dependency set up as "optional". 该库似乎使用Maven,并且具有一个POM文件,其依赖项设置为“可选”。 Here is the relevant section of the POM file: 以下是POM文件的相关部分:

<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. Gradle似乎没有将这个库包含在我的项目中,我猜它是因为“可选”属性。 Is there some way to tell Gradle to include this dependency without explicitly including the xz library myself? 有没有办法告诉Gradle包含这个依赖项而不自己明确地包含xz库?

Here is my Gradle dependency declaration: compile group: 'org.apache.commons', name:'commons-compress', version:'1.8.1' 这是我的Gradle依赖声明: 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.) (在Maven中也一样。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM