Commands in Maven

In this article, we will take a look at various maven commands. To create a new maven project

mvn archetype:generate -DgroupId=”org.softpost” -DartifactId=maventut 
-DarchetypeArtifactId=maven-archetype-quickstart  -DinteractiveMode=false

2. To create a jar/war/ear file in Maven
mvn package

The jar/war/ear file will be put in the target folder. Depending upon the packaging tag value in POM, the specific file is created. For example – If packaging has a value as jar, jar file will be created. 3. To install a jar file in local maven repository
mvn install

4. To create a website for maven project
mvn site

5. To clean maven project
mvn clean

6. To import the maven project in to IntelliJ IDEA
mvn idea:idea

7. To import the maven project in to Eclipse
mvn eclipse:eclipse

8. To execute install goal without running tests
mvn -Dmaven.test.skip=true install

9. To compile maven project
mvn -X compile

-X switch is used to enable full debug mode. We can use it with any valid maven command. 10. To see effective POM.xml file
mvn help:effective-pom

11. To see maven dependency tree
mvn dependency:tree

12. To execute all tests in Maven project
mvn test

Complex problems, Simple Solutions