Apache Maven Commands and Options

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information


Maven Commands

Let’s look into some popular and must know maven commands. We will use a sample Maven project to showcase the command output

1. mvn --version  or  mvn -v

It will prints out the version of maven you are running


2. mvn clean

It will cleans the maven project by deleting the target directory


3. mvn package

It will builds the maven project and packages them into a JAR, WAR, etc.
Note : The package goal executes compile and test before packaging the build


4. mvn clean package

It will clears the target directory and Builds the project and packages the resulting JAR file into the target directory
Note : The package goal executes compile and test before packaging the build


5. mvn verify

It will runs all integration tests found in the project

6. mvn clean verify

It will cleans the target directory, and runs all integration tests found in the project

7. mvn install

It will builds the maven project and installs the project files (JAR, WAR, pom.xml, etc) to the local repository

8. mvn test

It will run the test cases of the project using the maven-surefire-plugin

9. mvn -DskipTests package

The skipTests system property is used to skip the test cases from the build cycle. We can also use    
-Dmaven.test.skip=true to skip the test cases execution


10. mvn compiler:compile

It will compiles the java source classes of the maven project


11. mvn compiler:testCompile

It will compiles the test classes of the maven project

12. mvn validate

It will validates the maven project that everything is correct and all the necessary information is available


13. mvn dependency:tree

It will prints out the dependency tree for your project - based on the dependencies configured in the pom.xml file.

14. mvn dependency:analyze

It will analyzes the maven project to identify the unused declared and used undeclared dependencies. It’s useful in reducing the build size by identifying the unused dependencies and then remove it from the pom.xml file.


15. mvn dependency:build-classpath

It will prints out the classpath needed to run your project (application) based on the dependencies configured in the pom.xml file

Video Reference : 




Thanks
Saravanan Seenivasan
QA Lead Engineer





Comments

Popular posts from this blog

Create A REST API With JSON Server

Change The Default Port Number Of JSON-Server