Created
August 31, 2021 14:23
-
-
Save exaucae/7ae3d5790d47c5d92b018372ad3d92c3 to your computer and use it in GitHub Desktop.
maven plugins to fat jar your project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://stackoverflow.com/questions/20801874/how-to-build-an-executable-jar-from-multi-module-maven-project/20802018#20802018 --> | |
<!-- https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven?page=1&tab=votes#tab-top --> | |
<build> | |
<plugins> | |
<!-- mvn package --> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>3.2.4</version> | |
<configuration> | |
<minimizeJar>true</minimizeJar> | |
</configuration> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- alternative --> | |
<!-- mvn clean compile assembly:single --> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<configuration> | |
<appendAssemblyId>false</appendAssemblyId> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> | |
</descriptorRefs> | |
</configuration> | |
<executions> | |
<execution> | |
<id>make-assembly</id> <!-- this is used for inheritance merges --> | |
<phase>package</phase> <!-- bind to the packaging phase --> | |
<goals> | |
<goal>single</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- alternative --> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<configuration> | |
<appendAssemblyId>false</appendAssemblyId> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> | |
</descriptorRefs> | |
</configuration> | |
<executions> | |
<execution> | |
<id>make-assembly</id> | |
<phase>package</phase> | |
<goals> | |
<goal>single</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- alternative --> | |
<plugin> | |
<artifactId>maven-dependency-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>unpack-dependencies</id> | |
<phase>prepare-package</phase> | |
<goals> | |
<goal>unpack-dependencies</goal> | |
</goals> | |
<configuration> | |
<outputDirectory>${project.build.directory}/classes</outputDirectory> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- alternative --> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-jar-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>unpack-dependencies</id> | |
<phase>package</phase> | |
</execution> | |
</executions> | |
<configuration> | |
<archive> | |
<manifest> | |
<addClasspath>true</addClasspath> | |
<classpathPrefix>lib/</classpathPrefix> | |
</manifest> | |
</archive> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment