ivy: prevent downloading sources and .txt files

2019-03-04 15:29发布

问题:

How to tell IVY to not download source and .txt files. I have a dependency and it downloads license.txt files with it, when i use soemthing like this

<ivy:cachepath pathid="ivy-src-classpath" conf="compile"/>

it put the .txt files in the classpath which errors out while using java task

Unable to obtain resource from /home/muthiah/Work/ivy/cache/org.apache.commons/com.springsource.org.apache.commons.logging/licenses/license-1.1.1.txt: java.util.zip.ZipException: error in opening zip file

回答1:

In your ivy.xml file add a configuration mapping to the other module's "default" configuration:

<dependency org="commons-lang" name="commons-lang" rev="2.5" conf="compile->default"/>

Without this mapping you're retrieving both the default and optional dependencies of the remote module.

Another good mapping (for Maven modules) to use is:

conf="compile->master"

This will retrieve the remote artifact without it's transient dependencies.



回答2:

I had the same issue with multiple java.util.zip.ZipException: error in opening zip file in my ANT output logs, because there were licence .txt files in the classpath. The solution for me was to update the ivy:cachepath entry by adding type="jar":

<ivy:cachepath pathid="ivy-src-classpath" conf="compile" type="jar"/>

This will restrict only jar files to be added to the classpath.



标签: ivy