Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file?
I have a project the builds into a single jar file. I want the classes fro
http://fiji.sc/Uber-JAR provides an excellent explanation of the alternatives:
There are three common methods for constructing an uber-JAR:
- Unshaded. Unpack all JAR files, then repack them into a single JAR.
- Pro: Works with Java's default class loader.
- Con: Files present in multiple JAR files with the same path (e.g., META-INF/services/javax.script.ScriptEngineFactory) will overwrite one another, resulting in faulty behavior.
- Tools: Maven Assembly Plugin, Classworlds Uberjar
- Shaded. Same as unshaded, but rename (i.e., "shade") all packages of all dependencies.
- Pro: Works with Java's default class loader. Avoids some (not all) dependency version clashes.
- Con: Files present in multiple JAR files with the same path (e.g., META-INF/services/javax.script.ScriptEngineFactory) will overwrite one another, resulting in faulty behavior.
- Tools: Maven Shade Plugin
- JAR of JARs. The final JAR file contains the other JAR files embedded within.
- Pro: Avoids dependency version clashes. All resource files are preserved.
- Con: Needs to bundle a special "bootstrap" classloader to enable Java to load classes from the wrapped JAR files. Debugging class loader issues becomes more complex.
- Tools: Eclipse JAR File Exporter, One-JAR.