Command_Maven


mvn clean

cleans the maven project by deleting the target directory.

mvn install

Builds the project described by your Maven POM file and installs the resulting artifact (JAR) into your local Maven repository

mvn install -Dmaven.test.skip=true

Builds the project described by your Maven POM file without running unit tests, and installs the resulting artifact (JAR) into your local Maven repository

mvn clean install

Clears the target directory and builds the project described by your Maven POM file and installs the resulting artifact (JAR) into your local Maven repository

mvn clean install -Dmaven.test.skip=true

Clears the target directory and builds the project described by your Maven POM file without running unit tests, and installs the resulting artifact (JAR) into your local Maven repository

 

 

mvn compile / mvn compile:compile

compiles the java source classes

mvn compiler:testCompile

compiles the test classes

mvn test

run the test cases of the project using the maven-surefire-plugin.

 mvn idea:idea -U

 Update package

 

 

mvn clean package

Clears the target directory and builds the project and packages the resulting JAR file into the target directory.

mvn package -Dmaven.test.skip=true

Builds the project and packages the resulting JAR file into the target directory - without running the unit tests during the build.

mvn clean package -Dmaven.test.skip=true

Clears the target directory and builds the project and packages the resulting JAR file into the target directory - without running the unit tests during the build.

 

 

mvn -help

prints the maven usage and all the available options for us to use.

mvn validate

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

mvn verify

build the project, runs all the test cases and run any checks on the results of the integration tests to ensure quality criteria are met.

mvn clean verify

Cleans the target directory, and runs all integration tests found in the project.

mvn dependency:tree

generates the dependency tree of the maven project - based on the dependencies configured in the pom.xml file.

mvn dependency:analyze

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.

mvn dependency:tree -Dverbose

Prints out the dependency tree for your project - based on the dependencies configured in the pom.xml file. Includes repeated, transitive dependencies.

mvn dependency:tree -Dincludes=com.fasterxml.jackson.core

Prints out the dependencies from your project which depend on the com.fasterxml.jackson.core artifact.

mvn dependency:tree -Dverbose -Dincludes=com.fasterxml.jackson.core

Prints out the dependencies from your project which depend on the com.fasterxml.jackson.core artifact. Includes repeated, transitive dependencies.

mvn dependency:build-classpath

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

 

 

mvn dependency:copy-dependencies

Copies dependencies from remote Maven repositories to your local Maven repository.

mvn clean dependency:copy-dependencies

Cleans project and copies dependencies from remote Maven repositories to your local Maven repository.

mvn clean dependency:copy-dependencies package

Cleans project, copies dependencies from remote Maven repositories to your local Maven repository and packages your project.

 

 

mvn -o package

run the maven build in the offline mode. It’s useful when we have all the required JARs download in the local repository and we don’t want Maven to look for any JARs in the remote repository.

mvn -q package

Runs the maven build in the quiet mode, only the test cases results and errors are displayed.

mvn package

builds the maven project and packages the resulting Jar/War file into the target directory.

 

 

mvn deploy

This command is used to deploy the artifact to the remote repository. The remote repository should be configured properly in the project pom.xml file distribution Management tag. The server entries in the maven settings.xml file is used to provide authentication details.

mvn archetype:generate

Maven archetypes is a maven project templating toolkit. We can use this command to generate a skeleton maven project of different types, such as JAR, web application, maven site, etc.

mvn site:site

This command generates a site for the project. You will notice a “site” directory in the target after executing this command. There will be multiple HTML files inside the site directory that provides information related to the project.

mvn -f maven-example-jar/pom.xml package

build a project from a different location. We are providing the pom.xml file location to build the project. It’s useful when you have to run a maven build from a script.

mvn -X package

Prints the maven version and runs the build in the debug mode. It’s opposite of the quiet mode and you will see a lot of debug messages in the console.