views:

11

answers:

1

When specifing a dependancies 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?

A: 

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"/>
Mark O'Connor