<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>myproject.Main</mainClass> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> </manifest> <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins>
The maven-dependency plugin is used to copy the dependencies in the target/lib. The maven-jar-plugin is used to create a MANIFEST.MF file and automatically add the classpath as well as mainClass. You need to make sure that an empty MANIFEST.MF is present in the src/main/resources/META-INF.
Typo in org.apache.maven.plugins
ReplyDeleteShould be:
org.apache.maven.plugins
Thanks for the info.
Don
This comment has been removed by the author.
ReplyDeletetypo: groupId with capital I
ReplyDelete