Maven CLI flags control what gets built, how failures are handled, and how dependencies are resolved. This reference is for developers, build engineers, and CI maintainers who want faster, more predictable Maven runs and a quick way to pick the right options.
Originally published on 2013-09-12; fully revised and updated.
Original article: Maven commands Web References & Cheatsheet.

Maven CLI decision flow for day-to-day builds
flowchart TD
A[Start with mvn goal] --> B{Need partial reactor build}
B -- Yes --> C[Use -pl with -am or -amd]
B -- No --> D[Build full reactor]
C --> E{Previous run failed}
D --> E
E -- Yes --> F[Resume with -rf]
E -- No --> G[Choose failure policy]
F --> G
G --> H{Fast feedback needed}
H -- Yes --> I[Use -ff and maybe -T]
H -- No --> J[Use -fae]
I --> K[Run in CI with -B and -V]
J --> K
K --> L{Need fresh dependencies}
L -- Yes --> M[Use -U]
L -- No --> N[Use -o or -nsu]
High-value Maven options by category
| Category | Options | What they control | Typical use |
|---|---|---|---|
| Reactor scope | -pl, -am, -amd, -rf, -N | Which modules are built and where a build resumes | Monorepos and multi-module builds |
| Failure behavior | -ff, -fae, -fn | When Maven stops or continues after errors | Fast local feedback or full CI failure reporting |
| Dependency freshness | -U, -nsu, -o | Whether Maven checks remotes or stays offline | Snapshot troubleshooting, reproducible offline runs |
| Output and diagnostics | -q, -e, -X, -l, -V | How much logging is produced and where it goes | CI logs, debugging flaky builds |
| Environment files | -s, -gs, -t, -f | Alternate settings, toolchains, and POM path | Per-environment and per-pipeline customization |
| Automation and performance | -B, -T, -D | Batch mode, threading, and system properties | Non-interactive CI with controlled tuning |
Option comparisons that change build outcomes
| Goal | Prefer | Alternative | Trade-off |
|---|---|---|---|
| Stop immediately on first failure | -ff / --fail-fast | -fae / --fail-at-end | Fast signal, but fewer downstream failures discovered in one run |
| Run all modules and report failures at the end | -fae / --fail-at-end | -ff / --fail-fast | More complete failure picture, potentially longer runtime |
| Never fail process exit | -fn / --fail-never | -fae or -ff | Useful for diagnostics only; risky for release gates |
| Enforce artifact integrity strictly | -C / --strict-checksums | -c / --lax-checksums | Strict mode is safer; lax mode may hide repository issues |
| Run with no network dependency checks | -o / --offline | -nsu / --no-snapshot-updates | Offline is most reproducible; no-snapshot-updates still allows non-snapshot remote interactions |
| Force fresh remote metadata/artifacts | -U / --update-snapshots | Default update behavior | Can fix stale cache issues but may increase build time |
Practical command examples
Use these as starting points and adapt goals/phases to your pipeline.
mvn -B -V -e -T 1C clean verify
Build one module plus required upstream modules:
mvn -pl :api-service -am testCode language: CSS (css)
Resume a failed multi-module run from a specific module:
mvn -rf :payments-service verifyCode language: CSS (css)
Force remote snapshot/release checks when debugging stale artifacts:
mvn -U clean package
Use alternate settings and toolchains in CI:
mvn -s ~/.m2/settings-ci.xml -t ~/.m2/toolchains.xml deployCode language: JavaScript (javascript)
Capture all output to a log file for post-run analysis:
mvn -l build.log clean installCode language: CSS (css)
Complete CLI options reference from the original post
| Option | Description |
|---|---|
-am, --also-make | If a project list is specified, also build projects required by that list. |
-amd, --also-make-dependents | If a project list is specified, also build projects that depend on projects in that list. |
-B, --batch-mode | Run in non-interactive batch mode. |
-C, --strict-checksums | Fail the build if checksums do not match. |
-c, --lax-checksums | Warn if checksums do not match. |
-cpu, --check-plugin-updates | Ineffective; kept for backward compatibility. |
-D, --define <arg> | Define a system property. |
-e, --errors | Produce execution error messages. |
-emp, --encrypt-master-password <arg> | Encrypt master security password. |
-ep, --encrypt-password <arg> | Encrypt server password. |
-f, --file <arg> | Force use of an alternate POM file (or a directory with pom.xml). |
-fae, --fail-at-end | Only fail at the end; allow all non-impacted builds to continue. |
-ff, --fail-fast | Stop at first failure in reactor builds. |
-fn, --fail-never | Never fail the build, regardless of project result. |
-gs, --global-settings <arg> | Alternate path for the global settings file. |
-h, --help | Display help information. |
-l, --log-file <arg> | Write all build output to a log file. |
-llr, --legacy-local-repository | Use Maven 2 legacy local repository behavior (no _maven.repositories). Can also be activated with -Dmaven.legacyLocalRepo=true. |
-N, --non-recursive | Do not recurse into sub-projects. |
-npr, --no-plugin-registry | Ineffective; kept for backward compatibility. |
-npu, --no-plugin-updates | Ineffective; kept for backward compatibility. |
-nsu, --no-snapshot-updates | Suppress SNAPSHOT updates. |
-o, --offline | Work offline. |
-P, --activate-profiles <arg> | Comma-delimited list of profiles to activate. |
-pl, --projects <arg> | Comma-delimited list of reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by relative path. |
-q, --quiet | Quiet output; show errors only. |
-rf, --resume-from <arg> | Resume reactor from a specified project. |
-s, --settings <arg> | Alternate path for the user settings file. |
-T, --threads <arg> | Thread count, for example 2.0C where C multiplies available cores. |
-t, --toolchains <arg> | Alternate path for the user toolchains file. |
-U, --update-snapshots | Force a check for updated releases and snapshots on remote repositories. |
-up, --update-plugins | Ineffective; kept for backward compatibility. |
-V, --show-version | Display version information without stopping the build. |
-v, --version | Display version information. |
-X, --debug | Produce execution debug output. |
Best practices
- In CI, prefer
-Band include-Vso logs always show the Maven version used. - Use
-fffor fast developer feedback, and-faewhen you need a full failure report across modules. - Use
-Uselectively while troubleshooting cache or snapshot issues; avoid it by default if build speed is critical. - Pin environment-specific behavior with
-s,-gs, and-tinstead of relying on implicit local defaults. - Avoid
-fnin release or gating pipelines because it can mask real failures. - Verify option support in your installed Maven using
mvn -h, especially for flags marked as backward-compatibility only.
The original page also included a broken YouTube embed; the fallback link visible on that page points to: https://www.youtube.com/watch?v=ZCfrNvu6nMc.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals