🔧Maven- Project & Build Management Tool — Article #4

💻Important Commands Of MAVEN

Run Maven’s command using cmd

Fareena Imran
3 min readFeb 26, 2022

--

In this article, we are going to learn about the main commands of MAVEN. Let’s get started 👇

Maven commands start with ‘mvn’ and all the commands execute on the project level.

Maven commands start with ‘mvn’ and all the commands execute on the project level.

#1) mvn clean

This command cleans the project and deletes all temporary files, previous references, or builds whatever your current project has. So, usually, this is preferred before the execution of any test.

Use of ‘mvn clean’ command:

After you fix any error then it's better to clean the project. So you can use this command for cleaning your project.

#2) mvn compile

This command checks the syntax error of the code.

Use of mvn compile command:

When we run 100 test cases and got an error like missing semicolon or something like this then this command will the that got error at the line this in this class.

#3) mvn test

This command triggers all the tests in the src/test/java folder.

Use of ‘mvn test’ command:

If we use the ‘mvn test’ command directly without using the other two commands i.e. ‘mvn clean’ and ‘mvn compile’ then this command by default performs cleaning and compilation before test execution as a prerequisite. So you can directly use the ‘mvn test’ command.

For the first time, this command will take 1 or 2 minutes to load all the jar files from maven repository.

After downloading all the jar files and dependencies, it shows the result. Here, you can see all the tests result and result in descriptions 👆.

Cmd

You need to give the path of your project in cmd to run the mvn command otherwise you will get an error ‘The goal you specified requires a project to execute but there is no POM in this directory 👇

Give Project Path In Cmd

To give the path of your project just type “cd” and then drag your folder from eclipse-workspace after the word “cd”. cmd itself take the project path like this 👇

Follow all the articles to learn more about MAVEN.

Best of Luck 👍

Best of Luck 👍

--

--