Avoiding duplicate .jars libraries when exporting a single .jar to Eclipse

I use the Eclipse function "Export ... Runnable jar file" to package my Clojure + Java application for deployment.

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

The only problem I encountered was that the various libraries that I received included several times from the directory-dependent lib projects, for example. I get four versions of the Clojure jar file due to other projects in the build path that also use Clojure.

This problem once again increases the size of my .jar file!

Is there a way to easily remove these duplicates besides manually removing them from the generated jar?

+4
source share
1 answer

If there is a natural dependency graph for your projects, I would change the parameters of the eclipse project so that only one project has a jar in the build and export paths (for export, I mean from the Order and Export tab in the Configure Build Path dialog box "), which may be displayed for other projects. Other projects then have this β€œcore” project along the way. I believe this should take care of your problem.

Edit

One comment I have is that having a jar in a bank is rarely a good idea. I would either change my mind about packing all of this in a single jar (unless the point of the main jar file should not extract its own contents into a folder), or, perhaps, explore the possibility of using the option "Extract required libraries to the generated JAR".

+2
source

Source: https://habr.com/ru/post/1314334/


All Articles