Maven generate self-contained jar

2024-05-03 #dev #post

If your application is meant to run out of the box, it’s convenient for the users to get a single file and just execute it. For that, we need a way to bundle everything together in a big JAR file. For this task, we can use the Shade.


Add something like the following to your <build> section (within the pom.xml file):

                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">



Then build your package as usual (mvn clean package). The self-contained jar should be in the target/ directory with a name like myapp-1.0-SNAPSHOT-shaded.jar.