Useful maven commands

Project Build
Clean a project: mvn clean

Compile a project: mvn compile

Run unit tests (it also compiles a project): mvn test

Build a package (it also executes unit tests): mvn package

Run integration test (it also builds a package): mvn verify

Install a package into local repository (it also executes integration tests): mvn install

Install an artifact into local repository (skip integration test execution): mvn -DskipITs=true install

Install an artifact into local repository (skip unit and integration test execution): mvn -DskipTests=true install

Install an artifact into local repository (skip compiling test and test execution): mvn -Dmaven.test.skip=true

Deploy artifact into enterprise repository: mvn deploy

Project Site Generation

Generate site without tests reports (tests are not executed): mvn site:site

Generate site with unit tests reports: mvn test site:site

Generate site with unit and integration tests reports: mvn verify site:site

Generate site stage with valid links between project modules (for multimodule projects site stage is broken, look at issue 9): mvn test site:site site:stage or mvn verify site:site site:stage

Code Coverage Reporting
Generate Clover reports for unit tests: mvn clover2:setup test clover2:aggregate clover2:clover

Generate clover reports for unit and integration tests: mvn clover2:setup verify clover2:aggregate clover2:clover

Code Quality Analysis
Analyse code quality with Sonar: mvn sonar:sonar

Dependency Management

Check dependencies for newer versions: mvn versions:display-dependency-updates

Check plugins for newer versions: mvn versions:display-plugin-updates

Check for newer versions defined as properties: mvn versions:display-property-updates

Display project dependencies: mvn dependency:tree

Analyze project dependencies: mvn dependency:analyze

Getting Help

Display Help: mvn help

Display effective Maven settings: mvn help:effective-settings

Display effective POM: mvn help:effective-pom

Display all profiles (from settings.xml and POMs hierarchy): mvn help:active-profiles

Display plugin goals (for m-compiler-p in the example below): mvn compiler:help

Display plugin’s goal description (for goal compile in m-compiler-p in the example below): mvn compiler:help -Dgoal=compile -Ddetail

From http://code.google.com/p/m4enterprise/wiki/MavenCommandReference

Advertisements

About kishanthan

I’m currently working as a Software Engineer at WSO2, an open source software company. I hold an Engineering degree, majoring in Computer Science & Engineering field, from University of Moratuwa, Sri Lanka.
This entry was posted in How to, Java, Maven, Software and tagged , , , , , , , . Bookmark the permalink.

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