If you have a Java application, the easiest way to distribute this project is creating an executable fat-jar (or uber-jar) that can be started using
java -jar. With the help of Maven Assembly plugin, this can be easily implemented.
Below is the snippet of
pom.xml file that uses Maven Assembly plugin.
jar-with-dependencies is a built-in descriptor to generate a single jar file.
com.mycompany.myproject.Main is the main class that added to jar file's manifest to make this jar file executable.
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.1</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.mycompany.myproject.Main</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
mvn package, you should see a jar file with suffix
-jar-with-dependencies in the
target directory. This is the executable jar file to use for distribution.