Maven Commands

I’ve collected a short list of commands I use for maven and thought I’d share.

Install to Local Repository Compile Test Classes, Do Not Run Tests

mvn -Dmaven.test.skip.exec install

Install to Local Repository Do Not Compile Test Classes, Do Not Run Tests

 mvn -Dmaven.test.skip install

Generate Test Results in HTML Format (tests will be run)

mvn surefire-report:report

Generate Test Results in HTML Format (tests will not be run, source of reports will be last tests run)

mvn surefire-report:report-only

Run Specific Test Class

mvn -Dtest=MyTestClass test

Use Patterns to Run Specific Tests

mvn -Dtest=MyTest*lass test

Run Multiple Specific Test Classes

 mvn -Dtest=UnitTestClass,Accep*TestClass test

View Dependency Tree: output is a mono-spaced tree views of all classes in the current artifact

mvn dependency:tree

Download Sources: Usually when using Maven only the binary version of your dependency are fetched from the repository. This will tell Maven to download the sources of your dependencies.

mvn [goal] -DdownloadSources=true

Download Java Docs: Same as with sources, Maven doesn’t usually grab the JavaDocs.

mvn [goal] -DdownloadJavadocs=true

Show the Effective POM: This is the final pom that is used to perform the goal.

mvn help:effective-pom

Leave a Reply