MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Maven CLI Options Reference: Practical Flags, Comparisons, and Command Examples

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 options reference image from the original post

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

CategoryOptionsWhat they controlTypical use
Reactor scope-pl, -am, -amd, -rf, -NWhich modules are built and where a build resumesMonorepos and multi-module builds
Failure behavior-ff, -fae, -fnWhen Maven stops or continues after errorsFast local feedback or full CI failure reporting
Dependency freshness-U, -nsu, -oWhether Maven checks remotes or stays offlineSnapshot troubleshooting, reproducible offline runs
Output and diagnostics-q, -e, -X, -l, -VHow much logging is produced and where it goesCI logs, debugging flaky builds
Environment files-s, -gs, -t, -fAlternate settings, toolchains, and POM pathPer-environment and per-pipeline customization
Automation and performance-B, -T, -DBatch mode, threading, and system propertiesNon-interactive CI with controlled tuning

Option comparisons that change build outcomes

GoalPreferAlternativeTrade-off
Stop immediately on first failure-ff / --fail-fast-fae / --fail-at-endFast signal, but fewer downstream failures discovered in one run
Run all modules and report failures at the end-fae / --fail-at-end-ff / --fail-fastMore complete failure picture, potentially longer runtime
Never fail process exit-fn / --fail-never-fae or -ffUseful for diagnostics only; risky for release gates
Enforce artifact integrity strictly-C / --strict-checksums-c / --lax-checksumsStrict mode is safer; lax mode may hide repository issues
Run with no network dependency checks-o / --offline-nsu / --no-snapshot-updatesOffline is most reproducible; no-snapshot-updates still allows non-snapshot remote interactions
Force fresh remote metadata/artifacts-U / --update-snapshotsDefault update behaviorCan 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

OptionDescription
-am, --also-makeIf a project list is specified, also build projects required by that list.
-amd, --also-make-dependentsIf a project list is specified, also build projects that depend on projects in that list.
-B, --batch-modeRun in non-interactive batch mode.
-C, --strict-checksumsFail the build if checksums do not match.
-c, --lax-checksumsWarn if checksums do not match.
-cpu, --check-plugin-updatesIneffective; kept for backward compatibility.
-D, --define <arg>Define a system property.
-e, --errorsProduce 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-endOnly fail at the end; allow all non-impacted builds to continue.
-ff, --fail-fastStop at first failure in reactor builds.
-fn, --fail-neverNever fail the build, regardless of project result.
-gs, --global-settings <arg>Alternate path for the global settings file.
-h, --helpDisplay help information.
-l, --log-file <arg>Write all build output to a log file.
-llr, --legacy-local-repositoryUse Maven 2 legacy local repository behavior (no _maven.repositories). Can also be activated with -Dmaven.legacyLocalRepo=true.
-N, --non-recursiveDo not recurse into sub-projects.
-npr, --no-plugin-registryIneffective; kept for backward compatibility.
-npu, --no-plugin-updatesIneffective; kept for backward compatibility.
-nsu, --no-snapshot-updatesSuppress SNAPSHOT updates.
-o, --offlineWork 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, --quietQuiet 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-snapshotsForce a check for updated releases and snapshots on remote repositories.
-up, --update-pluginsIneffective; kept for backward compatibility.
-V, --show-versionDisplay version information without stopping the build.
-v, --versionDisplay version information.
-X, --debugProduce execution debug output.

Best practices

  • In CI, prefer -B and include -V so logs always show the Maven version used.
  • Use -ff for fast developer feedback, and -fae when you need a full failure report across modules.
  • Use -U selectively while troubleshooting cache or snapshot issues; avoid it by default if build speed is critical.
  • Pin environment-specific behavior with -s, -gs, and -t instead of relying on implicit local defaults.
  • Avoid -fn in 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.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
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.

Related Posts

Public Package Repositories by Programming Language

Public Package Repositories by Programming Language Public package repositories (also known as package registries, artifact repositories or dependency repositories) allow developers to publish, discover, download and manage…

Read More

Major programming languages, the common package tool(s), and the central community package repository.

Most programming languages pair a command-line package tool with a public registry it downloads dependencies from. Examples are cargo with crates.io, pip with PyPI, Maven with Maven…

Read More

Develocity: The Complete Beginner-to-Advanced Tutorial

A practical self-study course covering Developer Productivity Engineering, Build Scan, Build Cache, build acceleration, test optimization, architecture, deployment, integrations, security, and enterprise operations. 28 chapters | Beginner…

Read More

Jenkins Build and Release Training Blueprint: Git/SVN with Maven and Ant

This revised guide turns a legacy training announcement into a practical learning blueprint for build-and-release engineering. It maps the Jenkins workflow, compares core tools, and includes realistic command and pipeline examples.

Read More

Maven Release Plugin vs Maven Git Flow Plugin for Artifact Releases

Learn how Maven Release Plugin and Maven Git Flow Plugin automate Java artifact releases. Compare workflows, commands, and selection criteria for your branching strategy.

Read More

Sonatype Nexus Repository Manager: A Practical DevOps Introduction

Sonatype Nexus helps teams centralize dependency downloads and internal artifact publishing. This guide shows how Nexus fits into CI/CD, when to use hosted/proxy/group repos, and how to configure common build clients.

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
1 month ago

Knowing Maven CLI options can save time when running builds locally or in CI pipelines. Options such as skipping tests should be used carefully, since they can hide problems before a release. It is useful to learn how to select profiles, set properties, and control output for different environments. Keeping commonly used commands documented helps teams run builds consistently. Testing command changes on a small project first can prevent avoidable build failures.

1
0
Would love your thoughts, please comment.x
()
x