Tuesday, June 12, 2012


Some quick maven tips.

To run some code from a maven project
See this link http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/

mvn exec:java -Dexec.mainClass="com.vineetmanohar.module.Main" -Dexec.args="arg0 arg1 arg2"

Article explains 2 other ways from mvn pom.xml 

To run unit tests from a maven project
See this link http://maven.apache.org/plugins/maven-surefire-plugin/examples/single-test.html

mvn -Dtest=TestSquare,TestCi*le test
(Note can have wildcards in class names)
Can also specify methods (with wildcards)
mvn -Dtest=TestCircle#test* test
To not run tests
I used to use 
mvn -Dmaven.tests.skip install 
back when I used maven 2.x. 
However with maven 3, you can skip the entire test phase by this switch
mvn -DskipTests=true isntall

No comments: