Monday, 19 November 2012

Maven Commands

Build

To build a Maven based project, open your console, change to your project folder where pom.xml file is placed, and issue this command

“mvn package”

When we run “mvn package” command, it will compile source code, run unit test and pack it depends on your “packaging” tag in pom.xml file. For example,
If “packaging” = jar, it will package your project into a “jar” file and put it into your target folder

Also, when package phase is executed, all phases – “validate“, “compile” and “test“, including the current phase “package” will be executed orderly.

Clean

In Maven based project, many cached output existed in the “target” folder. so before build the project for deployment, we need to make sure to clean all the cached output so that we we will get the latest deployment To clean your project cached output, issue this command :

mvn clean

It is always recommended to run clean and package together.

Install

In Maven, use “mvn install” to package  project and deploy to local repository automatically, so that other developers can use it.

mvn install

When “install” phase is executed, all above phases “validate“, “compile“, “test“, “package“, “integration-test“, “verify” phase , including the current “install” phase will be executed orderly

It’s always recommended to run “clean” and “install” together, so that you are always deploy the latest project to your local repository.

 

 

Other commands

mvn eclipse:eclipse

mvn clean install -D maven.test.skip

No comments:

Post a Comment