Build Report Foundation — structured report, console modes, warning control - #12572
Draft
gnodet wants to merge 12 commits into
Draft
Build Report Foundation — structured report, console modes, warning control#12572gnodet wants to merge 12 commits into
gnodet wants to merge 12 commits into
Conversation
3 tasks
gnodet
force-pushed
the
feature/12571-build-report
branch
5 times, most recently
from
July 29, 2026 14:32
86a1ef4 to
3192bb4
Compare
…s, warning control Implements the build output overhaul proposed in #12571: - Structured BuildReport data model (BuildReport → ModuleReport → MojoReport) with JSON persistence to target/build-reports/ - DiagnosticCollector for deduplicated warning summaries with counts, suggestions, and doc URLs - Four --console modes: plain (CI), rich (TTY status bar), machine (JSON lines), verbose (Maven 4.0 default) - --warning-mode flag: summary (default), all, none, fail - Log.warn() interception for Maven 3 plugin warnings with synthetic dedup keys - Per-key diagnostic suppression via -Dmaven.diagnostic.suppress Rich mode uses JLine Display in non-fullscreen mode for a live status bar showing active modules, reactor progress, and download activity. All rich mode output bypasses SLF4J (routed through BuildEventListener.log) to avoid the ProjectBuildLogAppender filter chain. Warning/error counts are tracked and shown in the compact end-of-build summary. Machine mode emits one JSON object per line with typed events and ISO-8601 timestamps, designed for tools and LLM agents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
force-pushed
the
feature/12571-build-report
branch
from
July 29, 2026 14:59
3192bb4 to
87be78e
Compare
Add a lightweight tool to view previous build reports without running a full Maven build. Available both as a standalone `mvnlog` command and as a `mvnlog` subcommand within `mvnsh`. - LogOptions API with --diagnostics, --failures, --full, --list flags - LogInvoker skips DI container setup for fast startup - BuildReportRenderer shared between standalone and shell modes - SimpleJsonReader zero-dependency recursive descent JSON parser - Shell wrapper scripts for Unix and Windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ith parent -l (--log-file) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 12 ITs covering the full Build Report Foundation feature: - Build report JSON generation (single-module and multi-module) - Console modes: plain, machine, verbose, auto+CI detection - Warning mode suppression (--warning-mode=none) - Version info displayed on build failure - mvnlog viewer: summary, full view, list reports, no-report error Also fix shell script routing-flag passthrough: --debug, --yjp, --enc, --shell, --up, and --log are now stripped from $@ / %* before invoking Java, preventing Commons CLI partial-match collisions (e.g. --log was prefix-matching --log-file). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mvnlog --json outputs the raw build report JSON to stdout, making it easy to pipe to jq or other tools for programmatic consumption: mvnlog --json | jq '.modules[].artifactId' Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The separate filterArgs loop ran at the main scope where the arg_loop (which searches for -f/--file) had already shifted away all positional parameters. FILTERED_ARGS was always empty, causing "No goals specified" on every Windows build. Move the routing-flag filtering into the processArgs subroutine which runs inside a `call` frame with its own copy of %1..%N. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
context.interactive was still false (Java default) when createTerminal() cached the BuildEventListener via determineBuildEventListener(). The settings-based interactive-mode resolution only runs later in settings(). Add preliminaryInteractiveDetection() before createTerminal() to set context.interactive from CLI flags and CI detection early enough for the console-mode auto-detection to read it. Settings-based refinement still runs later in settings(). Also exclude embedded mode from rich auto-detection — embedded builds capture output via ByteArrayOutputStream, not a real terminal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The status bar already shows ✓/●/○ indicators and the [n/total] counter for each module, making the scrolling SUCCESS lines redundant. Only FAILURE and SKIPPED lines still scroll above the status bar since they're actionable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the fixed-slot display system with a dynamic status area that grows and shrinks with the active project count — no more empty lines when projects finish. Suppress WARN messages inline (just count them) and show them only in the end-of-build summary, keeping the scrollback clean during normal builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…hint Restore the fixed-height status area (based on concurrency) so the separator and summary line stay anchored at the bottom. Active projects are packed to the top; empty lines fill the gap at the bottom instead of between projects. When warnings are suppressed in rich mode, the end-of-build diagnostics line now tells the user to run "mvn --console=plain" to see the details. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The diagnostics summary now says "run mvnlog to see details" instead of "run mvn --console=plain" — mvnlog reads the build report from the last run so the user doesn't have to rebuild. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The default mvnlog summary now shows the actual diagnostic messages (not just the count), so users don't have to re-run the build to see what the warnings were. All durations (total time, module time, mojo time) are now formatted as human-readable "1:15 min" or "6.700 s" instead of raw ISO-8601 "PT1M15.396575333S". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the build output overhaul proposed in #12571: a structured
BuildReportdata model with JSON persistence, aDiagnosticCollectorfor deduplicated warning summaries, four--consolemodes (plain,rich,machine,verbose), a--warning-modeCLI flag, automaticLog.warn()interception for Maven 3 plugin warnings, per-key diagnostic suppression, and amvnlogbuild report viewer.What's included
Structured Build Report
BuildReport→ModuleReport→MojoReportdata model inmaven-api-corewithid()andfindModule()/findMojo()lookup methodsLogEventFailureReportwith timestamp, exception type, and stack traceBuildReportCollector(EventSpy,@Named @Singleton) — captures lifecycle eventsBuildReportJsonWriter— hand-written JSON serializer (no library dependency)target/build-reports/build-report-latest.jsonat session end, with timestamped historyorg.apache.maven.api.build.reportsub-packageDiagnosticCollector + Warning Summary
Diagnostic/DiagnosticCollector/DiagnosticSummaryAPIDefaultDiagnosticCollector— thread-safe (ConcurrentHashMap+LongAdder), dedup by key, capped at 1000build-report.jsonConsole Modes (
--console)--console=auto(default)plain; TTY →rich; otherwise →verbose--console=plain--console=rich--console=verbose--console=machinePlain mode: compact footer, no ANSI control sequences.
Rich mode: live
Displaybar showing active modules,[n/total]progress, elapsed time, download progress. All output bypasses SLF4J (routed throughBuildEventListener.log()) to avoid theProjectBuildLogAppenderfilter chain. Warning/error counts are tracked and shown in the compact end-of-build summary. Falls back gracefully on dumb terminals.Machine mode: one JSON object per line with typed
"event"field and ISO-8601 timestamps. Events:build.started/finished,module.started/succeeded/failed/skipped,mojo.*,fork.*,transfer.*.Warning Mode, Log Interception, Diagnostic Suppression
--warning-mode=summary(default)--warning-mode=all--warning-mode=none--warning-mode=failDiagnosticCollectorvia synthetic dedup keys (auto:<LoggerSuffix>:<hexHash>), with file-coordinate stripping so the same warning from different files deduplicates-Dmaven.diagnostic.suppress=<key>— suppress diagnostics by exact key or prefix wildcard (auto:*)Version Info on Failure (MNG-7372)
On
BUILD FAILURE, all console modes now display the Maven version and Java version/vendor in the summary. This helps with bug reports and Stack Overflow questions wherejava -versionoutput may not match the JDK Maven actually used.Build Report Viewer (
mvnlog)A lightweight tool to view previous build reports without running a full Maven build or an external plugin. Available in two forms:
mvnlog(ormvn --log) — skips DI container setup for fast startupmvnloginsidemvnsh— shares the shell session context--diagnostics/-d--failures/-f--full/-F--list/-Ltarget/build-reports/--json/-jjq)Positional argument accepts a path to a specific report file; defaults to
target/build-reports/build-report-latest.json.Key implementation details:
LogInvokerextendsLookupInvokerbut overridesdoInvoke()to skip the heavyweight DI container, settings, and repository setupSimpleJsonReader— zero-dependency recursive descent JSON parser (matches the zero-dependency spirit ofBuildReportJsonWriter)BuildReportRenderer— shared rendering logic between standalone andmvnshsubcommand viaConsumer<String>output patternLogOptionsAPI interface withCommonsCliLogOptionsCLI parsingmvnlog/mvnlog.cmd) for Unix and WindowsRich Mode Timing Fix
The console-mode auto-detection in
--console=autoreadscontext.interactiveto decide betweenrich/plain/verbose. However,createTerminal()caches theBuildEventListenerviadetermineBuildEventListener()early indoInvoke(), whilecontext.interactivewas only set later duringsettings(). This causedcontext.interactiveto befalse(Java default) at cache time, so rich mode never auto-activated on TTYs.Fixed by adding
preliminaryInteractiveDetection()beforecreateTerminal()— setscontext.interactivefrom CLI flags (--force-interactive,--non-interactive) and CI environment detection. The full settings-based resolution still runs later. Also excludes embedded mode from rich auto-detection since embedded builds capture output viaByteArrayOutputStream.Shell Script Routing-Flag Fix
The
mvn/mvn.cmdlauncher scripts now strip routing flags (--debug,--yjp,--enc,--shell,--up,--log) from the argument list before invoking Java. Previously these flags were consumed byhandle_args()to setMAVEN_MAIN_CLASSbut still passed through in$@/%*, where Commons CLI's partial long-option matching would collide (e.g.--logprefix-matched--log-file, causingmvnlog --helpto crash).What's NOT included (separate work)
Diagnosticobjects)Tests
74 unit tests across 12 test classes covering report assembly, JSON serialization, diagnostic dedup/suppression/concurrency, all console modes, warning modes, SLF4J bypass verification, warning summary display, version-on-failure behavior, JSON parsing, and build report rendering.
13 integration tests (
MavenITgh12571BuildReportTest) covering end-to-end behavior:plain,machine,verbose,autowithCI=true--warning-mode=nonesuppresses diagnosticsmvnlogviewer: summary view,--fullper-module detail,--listreports,--jsonraw output, error when no report existsIntegration tests that assert on verbose log output explicitly set
--console=verboseto work correctly under CI auto-detection.Supersedes
This PR supersedes and unifies the following open issues:
CIenv variable #11088 — Change maven CLI defaults based onCIenv variable (--console=autoauto-detects CI)build-report.jsonprovides per-mojo timing)Related:
-Tis a separate decision)