Maven Cheat Sheet
The Java build lifecycle — goals and phases, profiles, dependency diagnostics, and mvnw tricks.
Build & Package4 sections · 25 commands
⌘K
Lifecycle & Goals
7mvn clean installClean, build, test, package, and install-ish
mvn compileCompile sources only
mvn testRun unit tests
mvn package -DskipTestsPackage skipping tests
mvn verifyRun the full lifecycle incl. integration tests
mvn -DskipTests=false testForce tests on
mvn help:describe -Dplugin=maven-compilerDocs for a plugin
Dependencies
6mvn dependency:treeThe dependency graph
mvn dependency:tree -Dincludes=org.slf4jFilter the tree
mvn dependency:analyzeUsed vs declared vs unused
mvn -versionVersion, Java, and OS
mvn versions:display-dependency-updatesWhat's outdated
mvn dependency:purge-local-repository -DactTransitively=falseForce re-resolution
Profiles & Properties
6mvn package -PprodActivate a profile
mvn install -DskipTests -Dspotbugs.skip=trueSkip checks by property
mvn -q ...Quiet output
mvn -f path/pom.xml packageBuild an alternate POM
mvn help:active-profilesWhich profiles are active
./mvnw clean verifyUse the Maven wrapper
Debugging Builds
6mvn -e packageStacktrace on failure
mvn -X packageDebug logging
mvn -pl module -am testBuild one module + its dependencies
mvn -o packageOffline mode
mvn -B clean installBatch mode (no progress)
mvn siteGenerate project reports