Create executable jar package with dependencies
Lately I wrote myself some small GUI tools using Groovy’s SwingBuilder. To “install” them in my system I wanted to create a single JAR file containing all the required dependencies. Using the following maven plugin configuration it was very easy to achieve that:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Running the mvn assembly:assembly
command created the desired JAR file containing the MANIFEST file that runs the right Class on double clicking the JAR.