开发者

Avoiding duplicate library .jars when exporting a single .jar in Eclipse

开发者 https://www.devze.com 2023-01-05 01:56 出处:网络
I\'m using the Eclipse \"Export... Runnable jar file\" feature to package up my Clojure+Java application for deployment.

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 h开发者_StackOverflow中文版ave 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消