Skip to content


Maven Cheatsheet

Maven Quick Ref


Maven Basics

Maven Download / Install



  • Install:
cd /usr/local
ln -s apache-maven-3.0.5 maven
export PATH=/usr/local/maven/bin:$PATH
mvn -v
  • Settings file:

It contains user-specific configuration for authentication, repositories, and other information to customize the behavior of Maven.

  • Maven Repo:

This directory contains your local Maven repository. When you download a dependency from a remote Maven repository, Maven stores a copy of the dependency in your local repository.

Directory Layout

Introduction to the standard directory layout

Without customization, source code is assumed to be in ${basedir}/src/main/java and resources are assumed to be in ${basedir}/src/main/resources. Tests are assumed to be in ${basedir}/src/test, and a project is assumed to produce a JAR file. Maven assumes that you want the compile bytecode to ${basedir}/target/classes and then create a distributable JAR file in ${basedir}/target

For WAR files, the /WEB-INF directory contains a file named web.xml which defines the structure of the web application. See also Tomcat Deployment guide


  • Bring up a menu of choices
mvn archetype:generate -DgroupId=com.dw -DartifactId=es-demo -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  • Create a Java project
mvn archetype:create -DgroupId=org.yourcompany.project -DartifactId=application
  • Create a web project
mvn archetype:create -DgroupId=org.yourcompany.project -DartifactId=application -DarchetypeArtifactId=maven-archetype-webapp
  • Clean project (will delete target directory)
mvn clean
  • Validate project (validate the project is correct and all necessary information is available)
mvn validate
  • Compile project (compile source code, classes stored in target/classes)
mvn compile
  • Test project (run tests using a suitable unit testing framework)
mvn test
  • Package project (take the compiled code and package it in its distributable format, such as a JAR / WAR)
mvn package
  • Verify project (run any checks to verify the package is valid and meets quality criteria)
mvn verify
  • Install project (install the package into the local repository, for use as a dependency in other projects locally)
mvn install
mvn clean install -DskipTests -Dmaven.javadoc.skip=true
  • Deploy project (done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects)
mvn deploy
  • Deploy-file (can be used for deploying a external jar file to repository)
mvn deploy:deploy-file -Dfile=/path/to/jar/file -DrepositoryId=repos-server -Durl=http ://

You can run mvn site and then find an index.html file in target/site that contains links to JavaDoc and a few reports about your source code.

POM files

Use the search engine at to find dependencies by name and get the xml necessary to paste into your pom.xml