I have a project (of type \'jar\') that (obviously) builds a jar. But that project has many dependencies. I\'d like Maven to build a \"package\" or \"assembly\" that cont
Here is my solution to create a distributable .zip
(or .tar.gz
/ .tar.bz2
) including all dependencies in a lib
folder. It will:
jar
with a Manifest including the dependencies of the lib
directory as the classpath and the main class to run when executing the jar
.target/lib
directory.Excerpt from pom.xml
:
org.apache.maven.plugins
maven-jar-plugin
true
lib/
full.path.to.MainClass
maven-dependency-plugin
package
copy-dependencies
${project.build.directory}/lib
org.apache.maven.plugins
maven-assembly-plugin
package
attached
src/main/resources/dist.xml
dist.xml
:
bin
zip
tar.gz
${project.basedir}
/
README*
LICENSE*
NOTICE*
${project.build.directory}
/
*.jar
${project.build.directory}/lib
lib
*.jar
${project.build.directory}/site
docs
The dist.xml
was derived from the bin
descriptor format here: http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#bin