When a multi-module Maven build fails, how do `-e`, `-X`, `--fail-at-end`, and `--fail-never` change what happens and what you see?
answer
- -e = stack traces
- -X = debug logging (implies -e)
- default = fail-fast
- fail-at-end = build independents, still fails
- fail-never = always exit 0
basics
~10 s-e prints full stack traces on errors. -X enables verbose debug logging. --fail-at-end keeps building unaffected modules then reports all failures. --fail-never never fails the overall build regardless of module errors.
solid answer
~40 sThese are diagnostic and failure-policy flags. `-e`/`--errors` adds full exception stack traces to error output — the first thing to add when an error message is too terse. `-X`/`--debug` turns on debug-level logging for the whole build (very verbose: plugin config, dependency resolution, etc.); it implies `-e`. For the **reactor** (multi-module) failure behavior, the default is **--fail-fast**: stop at the first module that fails. `--fail-at-end` (`-fae`) lets Maven keep building all modules that don't depend on the failed one, then summarizes every failure at the end — great for seeing all problems in one CI run. `--fail-never` (`-fn`) builds everything and **always exits 0** even if modules failed — useful for report/scan jobs where you want full output but not a red build. Use `-X` sparingly (huge output); prefer `-e` first.
code
bash · 11 lines# Get full stack traces for a cryptic error
mvn clean install -e
# Verbose debug logging (plugin config, resolution)
mvn clean install -X
# Reactor: keep going, report every failure, still fail the build
mvn -fae verify
# Reactor: try everything, never fail the build (reporting only)
mvn -fn verifygo deeper
Know -e shows stack traces and -X is verbose debug.
Distinguish fail-fast default from fail-at-end and fail-never.
Choose the right flag for CI diagnostics vs gating and avoid hiding failures.
Set CI conventions: -fae for fast feedback on gating builds, -fn only for non-gating report jobs.
## Two categories: diagnostics and failure policy ### Diagnostic verbosity - **`-e` / `--errors`**: when a build throws an error, Maven normally prints a short message. `-e` adds the **full Java stack trace**, which often reveals the real cause (e.g. a plugin or dependency exception). Low cost, high value — add it first. - **`-X` / `--debug`**: enables **DEBUG-level logging** for the entire run. You see effective plugin configuration, dependency resolution decisions, mediation, classpath, repository checks, etc. It is extremely verbose and implies `-e`. Use it to debug 'why did Maven pick this version / run this plugin' type problems, then turn it off. - (Related: `-q`/`--quiet` reduces output to errors only.) ### Reactor failure policy (multi-module) In a multi-module (reactor) build, modules build in dependency order. What happens when one fails? - **`--fail-fast` (default)**: stop immediately at the first failed module. Remaining modules are skipped. - **`--fail-at-end` / `-fae`**: continue building every module that does **not** depend (transitively) on a failed module; modules that do depend on it are skipped. At the end, Maven prints a summary listing each module as SUCCESS / FAILURE / SKIPPED, and the overall build still **fails** (non-zero exit). Great in CI to surface all independent failures in one pass instead of fixing one, re-running, finding the next. - **`--fail-never` / `-fn`**: attempt all modules and **never** mark the overall build as failed — exit code 0 even with module failures. Used for non-gating jobs (e.g. generating reports/scans across all modules) where you want complete output without failing the pipeline. ## Putting it together ```bash # Terse error -> get the stack trace mvn install -e # Deep dive into plugin/dependency behavior mvn install -X | tee build-debug.log # See ALL module failures in one CI run (still fails overall) mvn -fae verify # Build everything, always green (reporting job) mvn -fn site ``` ## Judgement - Start with `-e`; escalate to `-X` only when you need internal decisions. - Prefer `-fae` in CI to reduce iteration cycles; reserve `-fn` for genuinely non-gating tasks so you don't hide real failures.
- What is the default reactor failure behavior?--fail-fast: Maven stops at the first failing module and skips the rest.
- Does `--fail-at-end` make the build pass?No. It builds all modules not depending on the failure and lists every result, but the overall build still exits non-zero if anything failed.
- When would `--fail-never` be dangerous?In a gating CI build — it always exits 0, so real failures would be hidden and broken artifacts could proceed.
saying these in an interview costs you the question
- Confusing `--fail-at-end` (still fails overall) with `--fail-never` (always passes).
- Reaching for `-X` before `-e` and drowning in output.
- Thinking `-e` changes build behavior — it only changes error output detail.