Tuesday, December 6, 2011

Maven commands - cheat-sheet


Option

Command

Description

Skip Junits

mvn clean install -DskipTests=true

Skips all the JUnits

Force Update

mvn -U clean install

Default behaviour of mvn clean install is to check the dependencies once a day.
If your teammates are changing the artifacts and you want to pick the latest from your local repository when you build, then go for this option.

Building from specified local repository

mvn clean
install -Dmaven.repo.local= /location_to_temp_repo

Before committing your changes, you want to be sure that you didn’t introduce any unavailable dependency. However, such dependencies may be in your local repository, and so you want to be sure they can still be retrieved and used.

Deleting your local maven repository completely may do the job, but … it’s not necessarily what you want.

The maven.repo.local variable allows configuring the local repository location of Maven.

This creates a complete new local repository at the specified location. In other words, you will compile your projects from scratch checking that you’re not using non-available artifacts from your (main) local repository. For sure it takes more time, but that’s the price to pay.

On windows I first tried mvn clean install –Dmaven.repo.local=c:\dev\temp-repo. It bombed saying C-plugin in not available etc. Then I tried with –Dmaven.repo.local=./temp-repo which downloaded the artifacts under c:\temp-repo (it creates) folder and built the same successfully. So, the path name should be reference to root.


Sources for this post:

1 comment: