views:

114

answers:

1

I'm using the Eclipse "Export... Runnable jar file" feature to package up my Clojure+Java application for deployment.

This works great, magically including various resources and Clojure source files etc.

The one issue I have is that various libraries I have get included multiple times from the "lib" directory dependant projects, e.g. I get four versions of the Clojure jar file due to other projects on the build path that also use Clojure.

This issue is needlessly tripling the size of my .jar file!

Is there any way to easily eliminate these duplicates other than manually deleting from the generated jar?

+2  A: 

If there is a natural dependency graph to your projects, I would change your eclipse project settings such that only one project has the jar on the build path and it exports (by export I mean from the "Order and Export" tab in the Configure Build Path dialog) that jar for other projects to see. The other projects then have that "core" project on the build path. I believe this should naturally take care of your problem.

Edit

One comment I have is that having a jar within a jar is rarely a good idea. I would either reconsider packaging it all into a single jar (unless the point of the main file of the jar is to extract its own contents into a folder) or maybe explore the possibility of using the "Extract required libraries into generated JAR" option.

Mark Peters
Thanks this is very useful advice. I'm feeling that the "extract required libraries into generated jar" may be the best approach though I'm a little sensitive about the potential gotchas, e.g. duplicate file names.....
mikera
@mikera: The issue of duplicate file names is largely a non-issue if you're using package names correctly and effectively.
Mark Peters