My Maven2 Cheat Sheet

Here are some Maven2 command lines that I use most often:

To create a new project:

mvn archetype:create -DgroupId=com.mbledug.foo -DartifactId=bar

To generate Eclipse project descriptor after configuring the dependencies in pom.xml:

mvn eclipse:eclipse

To run unit tests, obviously:

mvn test

Tun run a single test by test class name:

mvn test -Dtest=FooBar

To generate site documentation without running the tests (handy while updating the APTs):

mvn -Dmaven.test.skip=true clean site

To build the package file (jar, war, etc) allowing test failure:

mvn -Dmaven.test.failure.ignore=true package

To distribute the source code:

mvn assembly:assembly -DdescriptorId=src

To install a jar file on local repo:

mvn install:install-file -Dfile=foo.jar -DgroupId=bar -Dversion=x.y -Dpackaging=jar -DartifactId=blah

To release an artifact (create a tag in the SCM and bump up SNAPSHOT version in the pom):

mvn release:prepare release:perform
Share Comments
comments powered by Disqus