asela38
asela38

Reputation: 4644

How to exclude a particular package form a dependency?

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?

Upvotes: 2

Views: 2426

Answers (1)

Mark O'Connor
Mark O'Connor

Reputation: 77971

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"/>

Upvotes: 1

Related Questions