Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you configure Apache Ivy to remove orphan artifacts?

Tags:

java

ant

ivy

Let's say I have an ivy.xml that contains the following:

  <dependency org="checkstyle" name="checkstyle" rev="4.3" />

And then I want to upgrade to Checkstyle 4.4, so I change my ivy.xml to contain:

  <dependency org="checkstyle" name="checkstyle" rev="4.4" />

After a retrieve with the first configuration, I have the file checkstyle-4.3.jar. After the second configuration, I also have the file checkstyle-4.4.jar, and the file checkstyle-4.3.jar still exists.

Is there a way to have Ivy realize that the old file is an orphan, and remove it from the lib directory? The idea is that I don't want my developers' disk space usage to drastically increase every time I upgrade a tool.

Ideally I'd also want it removed from the local repository as well. I do realize that the intent of the local repository is that it is shared among projects, so it would not make sense to remove anything, as it would not know if the artifact was still in use in other projects. But there must be some kind of prune procedure...

like image 961
Jared Oberhaus Avatar asked Apr 18 '09 04:04

Jared Oberhaus


1 Answers

I've been using Ivy 2.0.0, so I don't know if this applies to the version you're using.

The Ivy retrieve task has a sync attribute. Set this to true and unused/unknown files in your retrieved directory (lib in your case) will be removed. Keep in mind this will mean any manually copied artifacts in this directory which Ivy doesn't specifically resolve will be removed.

Also, note that if you use the sync option but Ivy resolves no dependencies (empty or missing ivy.xml, for example), the retrieve directory will be deleted.

like image 151
Phil M Avatar answered Nov 03 '22 06:11

Phil M