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.
-
mvn clean This command cleans the maven project by deleting the target directory.
-
mvn compiler:compile This command compiles the java source classes of the maven project.
-
mvn package This command builds the maven project and packages them into a JAR, WAR, etc.
-
mvn install This command builds the maven project and installs the project files (JAR, WAR, pom.xml, etc) to the local repository.
-
mvn deploy This command is used to deploy the artifact to the remote repository.
-
mvn validate This command validates the maven project that everything is correct and all the necessary information is available.
-
mvn dependency:tree This command generates the dependency tree of the maven project.
-
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 test This command is used to run the test cases of the project using the maven-surefire-plugin.
-
mvn compile It’s used to compile the source Java classes of the project.
-
mvn verify This command 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.