Maven Commands List PDF
Maven Commands List PDF
javaguides.net/2018/12/maven-commands-list-pdf.html
In this post gives you all the useful maven commands used in maven applications.
mvn archetype:generate
-DgroupId=org.yourcompany.project
-DartifactId=application
-DarchetypeArtifactId=maven-archetype-webapp
mvn archetype:create-from-project
2. Main phases
clean — delete target directory
validate — validate, if the project is correct
compile — compile source code, classes stored in target/classes
test — run tests
package — take the compiled code and package it in its distributable format, e.g. JAR,
WAR
verify — run any checks to verify the package is valid and meets quality criteria
install — install the package into the local repository
mvn clean
1/4
validate project: validate the project is correct and all necessary information is available
mvn validate
mvn compile
mvn test
package project: take the compiled code and package it in its distributable format, such as a
JAR /WAR
mvn package
verify project: run any checks to verify the package is valid and meets quality criteria
mvn verify
install project: install the package into the local repository, for use as a dependency in other
projects locally
mvn install
deploy project: done in an integration or release environment, copies the final package to the
remote repository for sharing with other developers and projects
mvn deploy
mvn site:site
2/4
mvn verify site:site
It is much more feasible to generate code coverage reports directly from IDE than from Maven.
Write test, write code, run coverage for separated test, and check that all important branches are
covered.
7. Dependency Management
Check dependencies for newer versions:
mvn versions:display-dependency-updates
mvn versions:display-plugin-updates
mvn versions:display-property-updates
mvn dependency:tree
mvn dependency:analyze
3/4
8. Getting Help
Display effective Maven settings:
mvn help:effective-settings
mvn help:effective-pom
mvn help:active-profiles
mvn compiler:help
Display plugin's goal description (for goal compile in m-compiler-p in the example below):
Help plugin — used to get relative information about a project or the system.
mvn help:describe describes the attributes of a plugin
mvn help:effective-pom displays the effective POM as an XML for the current build, with
the active profiles factored in. Dependency plugin — provides the capability to
manipulate artifacts.
mvn dependency:analyze analyzes the dependencies of this project
mvn dependency:tree prints a tree of dependencies Compiler plugin — compiles your
java code. Set language level with the following configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</
artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
4/4