Skip to the content.

maven cheat sheet

Docker

Run maven container with docker using a different user than root:

CLI

POM

Settings

# Specify settings.xml file from mvn cli
mvn -s <path/to/settings.xml> <goals or phases>
mvn -s ~/.m2/settings-custom.xml clean install

# Specify local repository path/location
mvn -Dmaven.repo.local=<pat/to/local/repo>

Useful Plugins

Help Plugin

# Check which profiles are actives
mvn help:active-profiles

# Get effective pom
mvn help:effective-pom -Doutput=effective-pom.xml

# To get value of maven property
mvn help:evaluate -Dexpression=project.version -q -DforceStdout -N

Dependency Plugin

# To view dependency tree
mvn dependency:tree

Exec Plugin

# Get maven project version
mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec

More Info