2

When specifing a dependencies using ant ivy, is there a way to exclude a particular package?

eg: I am putting a dependency to MyJar.jar

it has packages

com.test.one
com.test.one.first
com.test.one.second
com.test.two
etc.

I want to exclude the package com.text.one.first.

If there is a way, how can i do that?

1 Answer 1

1

Ivy downloads modules that contain one or more jar files (called artifacts) and which might in turn declare dependencies on other modules.

The exclude directive can be used to prevent the download of certain artifacts

<dependency name="myjar" rev="1.0">
  <exclude module="idontlikethismodule"/>
</dependency>

What ivy cannot do is open up a jar and only download certain packages.

If that is your requirement then I'd suggest downloading the jar and then repackaging it using the ANT unzip and jar commands.

Something like:

<ivy:retrieve pattern="lib/[artifact].[ext]"/>
<unzip src="lib/myjar.jar" dest="build/unzip"/>
<jar destfile="build/mynewjar.jar" basedir="build/unzip" excludes="com.text.one.first"/>

Not the answer you're looking for? Browse other questions tagged or ask your own question.