Gradle Does Not Include Optional Dependency

时光毁灭记忆、已成空白 提交于 2020-01-29 07:12:14

问题


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'


回答1:


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



来源:https://stackoverflow.com/questions/26219788/gradle-does-not-include-optional-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!