LinuxCommandLibrary

maven

TLDR

Compile project

$ mvn compile
copy
Run tests
$ mvn test
copy
Package (create JAR/WAR)
$ mvn package
copy
Install to local repository
$ mvn install
copy
Clean build artifacts
$ mvn clean
copy
Skip tests during build
$ mvn package -DskipTests
copy
Run specific goal
$ mvn dependency:tree
copy

SYNOPSIS

mvn [options] [goal...]

DESCRIPTION

Maven is a build automation and project management tool for Java. It manages dependencies, compiles code, runs tests, and packages applications based on the Project Object Model (pom.xml).
Maven follows convention over configuration, using standard directory layouts and build lifecycles.

PARAMETERS

clean

Remove build directory.
compile
Compile source code.
test
Run unit tests.
package
Create JAR/WAR.
install
Install to local repo.
deploy
Deploy to remote repo.
-DskipTests
Skip test execution.
-U
Force update snapshots.
-o, --offline
Offline mode.
-P profile
Activate profile.

PROJECT STRUCTURE

$ project/
├── pom.xml
├── src/
│   ├── main/java/
│   └── test/java/
└── target/
copy

CAVEATS

Requires pom.xml. First run downloads dependencies. Local repository in ~/.m2. Plugins extend functionality.

HISTORY

Maven was created at the Apache Software Foundation in 2002 by Jason van Zyl as a successor to Apache Ant, emphasizing convention over configuration.

SEE ALSO

gradle(1), ant(1), java(1), mvnw(1)

Copied to clipboard