In the pom.xml file ...
1) Add this code to your project-> node properties. This will define your main class in a central location for use in many plugins.
<properties> <mainClass>project.Main.class</mainClass> </properties>
2) Add this code to your project-> build-> plugins node. It will collect all your jar dependencies in the lib folder and compile your main jar class with the corresponding classpath link:
<plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>install</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>${mainClass}</mainClass> </manifest> </archive> </configuration> </plugin>
source share