maven
Maven 3.9+Quick reference for Maven CLI commands: project lifecycle phases, dependency management, plugins, multi-module reactors, repository deployment, and debugging — with common options and practical examples.
34 commands
Lifecycle phases
mvn validateValidate the project structure: download metadata, parse `pom.xml`, sanity-check dependencies.
-N only the root reactor (no submodules); -f <pom> use alternate POM; -P<profile> enable profile
mvn validatemvn compileCompile the project's main `src/main/java` into `target/classes`. Uses the configured JDK and `maven-compiler-plugin`.
-DskipTests; -T 4 parallel build threads; -q quiet
mvn compilemvn testRun unit tests (Surefire) against compiled main + test sources. Skips `failsafe` (integration tests) — use `mvn verify` for that.
-Dtest=ClassName; -Dtest=Class#method; -DfailIfNoTests=false; -Dsurefire.useFile=false
mvn test -Dtest=UserServiceTestmvn packageRun every prior phase, then package the compiled output into a JAR / WAR / EAR under `target/`.
-DskipTests; -Dpackaging=jar
mvn package -DskipTestsmvn verifyRun package plus integration tests (Failsafe), then verify everything is shippable. Does **not** install or deploy.
-DskipITs; -DskipTests
mvn verify -DskipITsmvn installRun verify, then copy the produced artifact into the local Maven repository (`~/.m2/repository`) so other local projects can depend on it.
mvn install -DskipTestsmvn deployBuild and push the artifact to the remote repository declared in `pom.xml`'s `<distributionManagement>` (Nexus / Artifactory / Maven Central via Sonatype).
-DskipTests; -P release use release profile
mvn deploy -P release -DskipTestsmvn cleanDelete the `target/` directory to start from a fresh state.
mvn cleanmvn clean installWipe `target/` then run through `install`. The most common "rebuild from scratch" command.
-U force-update of snapshot dependencies
mvn clean install -UDependencies
mvn dependency:treePrint the resolved dependency tree (with conflict resolution) — invaluable for chasing `NoSuchMethodError` from version skew.
-Dincludes=<groupId>[:<artifactId>[:<version>]]; -Dverbose
mvn dependency:tree -Dincludes=com.fasterxml.jackson.coremvn dependency:resolveResolve every dependency into the local repo without executing the lifecycle.
mvn dependency:resolvemvn dependency:analyzeCompare declared `<dependencies>` against actual `import` / `package` usage; flags unused / undeclared deps.
mvn dependency:analyzemvn dependency:listList every resolved dependency in the build as plain `groupId:artifactId:type:version` lines.
mvn dependency:list | grep slf4jmvn versions:display-dependency-updatesList every dependency that has a newer version available in the configured repositories.
mvn versions:display-dependency-updatesMulti-module
mvn -pl <module> <goal>Run a goal against one or more specific submodules by artifact ID (comma-separated).
-am also build the modules the target depends on
mvn -pl user-service,order-service -am testmvn -pl <module> -am <goal>Build the named module plus every module it depends on. `-amd` (also-make-dependents) is the inverse.
mvn -pl web -am packagemvn -T 4 <phase> / mvn -T 1C <phase>Parallel reactor: `-T 4` uses 4 threads; `-T 1C` uses 1 thread per CPU core. Speeds up multi-module builds.
mvn -T 1C clean installRepository
mvn help:effective-pomPrint the final merged POM (super-POM + parent POM + active profiles + current settings) to a single file — the source of truth at build time.
-Doutput=<file>
mvn help:effective-pom > effective.xmlmvn help:effective-settingsPrint merged `~/.m2/settings.xml` + global + CLI-`--settings`. Useful for chasing mirror / credential resolution.
mvn help:effective-settings -s ./settings.xmlmvn -s <settings.xml> <phase>Override the user `settings.xml` for one build — handy for CI with mirrored repos.
mvn -s ./.mvn/settings.xml deployPlugins
mvn <plugin>:<goal>Run a single plugin goal directly. Common: `compiler:compile`, `surefire:test`, `jar:jar`, `deploy:deploy`, `dependency:tree`.
-D<param>=<value> goal parameter; -X debug (very verbose)
mvn compiler:compile && mvn surefire:test -Dtest=*ServiceTestmvn help:describe -Dplugin=<id>Show every goal and parameter of a plugin. Substitute `<id>` with the `groupId:artifactId`.
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-pluginProfiles
mvn -P<profile1>,<profile2> <phase>Activate one or more profiles declared under `<profiles>` in `pom.xml` or `settings.xml`.
mvn -Pprod,fast testmvn -P!<profile> <phase>Deactivate a profile that would otherwise be active by default.
mvn -P!javadoc packageDebugging
mvn -X <phase>Enable debug logging — prints every plugin execution, repository lookup, and download URL. Pipe to file.
-e full stack traces on errors
mvn -X test > mvn-debug.log 2>&1mvn -e <phase>Print full stack traces on any failure. Combine with `-X` for maximum detail.
mvn -e -X deploymvnDebug <phase>Start the build with the JVM suspended on a JDWP socket (default port 8000) so you can attach a debugger at line 1 of the Maven JVM.
mvnDebug testWrapper
./mvnw <phase>Run a build through the Maven Wrapper — uses the Maven version pinned in `.mvn/wrapper/maven-wrapper.properties`. Always check in the wrapper.
-Dmaven.version=<ver> upgrade Maven for this run
./mvnw clean installmvn wrapper:wrapperGenerate / refresh the Maven Wrapper files (`mvnw`, `mvnw.cmd`, `.mvn/wrapper/*`).
-Dmaven=<version> pin the Maven distribution version
mvn wrapper:wrapper -Dmaven=3.9.6Misc
mvn --versionPrint Maven version, JDK, OS, and locale.
mvn --versionmvn --helpList every CLI flag and supported property.
mvn --help | head -40mvn -B <phase>Batch / non-interactive mode — disables interactive prompts and color output. Use in CI to avoid hanging on a missing property.
mvn -B -ntp clean verifymvn -ntp <phase>Disable the new transfer-progress bar (recommended in CI; reduces log noise and avoids CPU spikes on slow mirrors).
mvn -B -ntp clean deploymvn -o <phase>Offline mode — never call out to remote repositories. Fails fast if a required artifact isn't in the local repo.
mvn -o testRelated command cheatsheets
mvnd
Quick reference for Maven Daemon (mvnd) — a long-lived JVM wrapper around `mvn` that keeps a background daemon to skip JVM startup on every build. Same CLI as Maven, plus daemon management commands.
29 commands
Maven Daemon 1.0+
gradle
Quick reference for the Gradle CLI: project tasks, dependency management, multi-project builds, wrapper, configuration cache, and build scan — with common options and practical examples.
30 commands
Gradle 8+
Trademark & Use Notice
These command-line tool cheatsheets are open community references. The names, logos, and trademarks of the tools referenced here (such as Git™, Docker™, Kubernetes®, kubectl, PostgreSQL®, MySQL®, Redis™, MongoDB®, Linux™, PowerShell™, Vim™, and others) are the property of their respective owners and are used here solely for identification and reference purposes.
All content in these cheatsheets is independently authored as a simplified, self-contained reference. It is not affiliated with, endorsed by, or sourced from any official documentation. Command listings, flag descriptions, and examples are original simplifications; for authoritative information please consult the official documentation of each tool.
Command syntax and option flags may differ across tool versions. The version tags shown reflect stable releases; behavior may differ in other versions. This cheatsheet does not imply any preference or recommendation by the trademark holders.
If a trademark or copyright owner believes that any content on this site infringes their rights, please send an email to [email protected]. Upon receiving valid proof of rights, we will modify or remove the relevant content within a reasonable period.
This website assumes no legal liability for any direct or indirect losses arising from the use of information presented on these pages.
About Maven
Apache Maven is a Java project management and comprehension tool that debuted in 2002 (originally created by Jason van Zyl). It models a project with a declarative `pom.xml` (Project Object Model) and executes a well-defined build lifecycle with eight default phases: `validate`, `compile`, `test`, `package`, `verify`, `install`, `deploy`. Maven was the first mainstream Java build tool to enforce a single repository layout (`groupId:artifactId:version`) and dependency resolution from a remote repository (Maven Central). The current stable line is Maven 3.9+. Maven downloads artifacts into the local repository (`~/.m2/repository` by default) and resolves transitively, with optional scopes (`compile`, `provided`, `runtime`, `test`, `system`, `import`). Plugins extend the lifecycle; common ones include `maven-compiler-plugin`, `maven-surefire-plugin`, `maven-jar-plugin`, and `maven-deploy-plugin`. Profiles (`-P`) override defaults per environment. Maven never uploads source code — `deploy` only ships the artifacts (jar/war/pom) configured in `distributionManagement`. Wrapper scripts (`mvnw` / `mvnw.cmd`) ship a Maven version per-project to lock the toolchain.
Cheatsheet version 1.0.0