StackTips

Popular Maven Commands Cheat Sheet

nilan avtar

Written by

Nilanchala,  4 min read,  2.52K views, updated on Jan. 08, 2024

Here are some of the most popular Maven commands that every Java developer must know:

    mvn clean: This command is used to clean the project's target directory, which contains the compiled classes and generated artifacts. It removes all files generated during the build process.

        mvn compile: This command is used to compile the source code of the project.

            mvn test: This command is used to run the tests for the project.

                mvn package: This command is used to create an executable JAR or WAR file of the project.

                    mvn install: This command is used to install the project's JAR or WAR file into the local Maven repository.

                        mvn deploy: This command is used to deploy the project's JAR or WAR file to a remote Maven repository.

                            mvn dependency:tree: This command is used to display the project's dependency tree, showing all the dependencies and their transitive dependencies.

                                mvn help: This command is used to display the Maven help information, including the available commands and their descriptions.

                                    mvn archetype:generate: This command is used to generate a new Maven project based on a specified project template, also known as an archetype.

                                        mvn site: This command is used to generate the project's documentation site, including reports on code quality, test results, and more.

                                          These are just a few of the most popular Maven commands, but there are many more available.

                                          By using these commands, you can easily build, test, and deploy your Java projects, and manage their dependencies and documentation.

                                          Getting Started with Java - Beginner's Guide

                                          This course covers the fundamental aspects of core Java programming and provides a structured path for beginners to learn and practice Java programming.

                                          >> CHECK OUT THE COURSE

                                          Continue reading..