comments 2

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
About these ads

2 Comments

  1. Wim Deblauwe

    If you want a fast way to edit your APT files, use ‘mvn site:run’. That way, you can edit them on the fly. Just save the file and reload it in your browser.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s