You will use the maven-dependency-plugin to copy project dependencies to another location.
Add this to pom.xml
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.mkyong.core.App</mainClass> <classpathPrefix>dependency-jars/</classpathPrefix> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.5.1</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory> ${project.build.directory}/dependency-jars/ </outputDirectory> </configuration> </execution> </executions> </plugin>
The following manifest file will be created. Project dependencies will be copied to {project} / target / dependency-jars /.
manifest-Version: 1.0 Built-By: mkyong Build-Jdk: 1.6.0_35 Class-Path: dependency-jars/log4j-1.2.17.jar Created-By: Apache Maven Main-Class: com.mkyong.core.App Archiver-Version: Plexus Archiver
It worked for me. Source: MKyong.com
source share