tags:

views:

176

answers:

1

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...

+4  A: 

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.

Phil M
That's exactly what I was looking for, thanks! By the way, I'm using 2.1.0-RC1.
Jared Oberhaus
By the way, I've determined that this does not remove the items from the cache. Therefore the benefit is that you won't have multiple versions of the same jar in your lib directory (which is important), but you won't save much disk space. An occasional ivy:cleancache will do that job.
Jared Oberhaus