MAVEN Cheat Sheet!!!!

Sri Priya P Kulkarni
2 min readFeb 18, 2024

--

Maven

What is Maven?

Maven is a powerful project management tool that is based on POM (project object model). It is used for projects build, dependency and documentation.

Create a New Maven Project

mvn archetype:generate -DgroupId=com.example -DartifactId=myproject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Build Maven Project

mvn clean install

Run Maven project

mvn test

How to add Dependencies in `pom.xml`

In pom.xml file, we need to the dependencies as below:

dependency

How to specify Plugins in pom.xml:

plugins

How to run a specific test:

mvn -Dtest=TestClassName test

How to skip tests during Build:

mvn install -DskipTests

How to clean the Maven project:

mvn clean

How to check the Maven version:

mvn -version

How to display effective pom.xml:

mvn help:effective-pom

How to update snapshots:

mvn clean install -U

How to run maven build with profiling:

mvn clean install -PprofileName

Executing Goals in a Specific Phase:

mvn <phase>:<goal>

How to create Maven Project with Custom Archetype:

mvn archetype:generate -DarchetypeGroupId=mygroup -DarchetypeArtifactId=myarchetype

How to view Maven Dependency tree:

mvn dependency:tree

These are the basic maven commands of Maven.

Happy Testing!!!

--

--

Sri Priya P Kulkarni

SDET| Blogger! | Automation Enthusiast! | On a journey of Continuous learning.... !