Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Does Not Include Optional Dependency

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'

like image 716
jjathman Avatar asked Oct 06 '14 15:10

jjathman


1 Answers

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

like image 100
Peter Niederwieser Avatar answered Oct 11 '22 12:10

Peter Niederwieser