Nov 27, 2010 0
Howto package executable JARs with Maven
If you want to build your project as executable JAR with maven, the maven assembly plugin would be useful.
<descriptorRef>jar-with-dependencies</descriptorRef>
part causes the dependent libraries to be packed into the JAR together with your project sources. “mainClass” of manifest section configures “Main-Class:” of Manifest file of an executable JAR.
<plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.foo.MainClass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins>
now run mvn with assembly:assembly
$ mvn -e clean assembly:assembly
Good Luck!


