Build Report Foundation — structured report, console modes, warning control - #12572
Draft
gnodet wants to merge 1 commit into
Draft
Build Report Foundation — structured report, console modes, warning control#12572gnodet wants to merge 1 commit into
gnodet wants to merge 1 commit into
Conversation
3 tasks
gnodet
force-pushed
the
feature/12571-build-report
branch
6 times, most recently
from
July 29, 2026 14:59
3192bb4 to
87be78e
Compare
This was referenced Jul 31, 2026
…s, warning control Add a comprehensive build reporting infrastructure to Maven 4.1.0: **Structured Build Report** (Phase 0-1) - BuildReport API in maven-api-core with ModuleReport, MojoReport, FailureReport, and LogEvent data model - BuildReportCollector EventSpy that captures lifecycle events, per-mojo log output, and build diagnostics - JSON writer producing timestamped build-report-*.json files - Deduplicated warning summary printed at end of build **Console Modes** (Phase 2-4) - ConsoleMode enum (AUTO/PLAIN/RICH/MACHINE) with --console CLI flag - PlainBuildEventListener for compact CI output - RichBuildEventListener with JLine status bar for interactive terminals - MachineBuildEventListener for JSON-lines structured output **Warning Control** (Phase 5) - --warning-mode CLI flag (ALL/SUMMARY/NONE) - Log.warn() interception for automatic Maven 3 plugin coverage - -Dmaven.diagnostic.suppress=key for selective suppression **Build Log Viewer** (mvnlog) - mvnlog CLI tool for post-build report inspection - --json flag for raw JSON output - Shell scripts for Unix and Windows **Plugin API** (DiagnosticReporter) - BuilderProblem.builder() static factory with fluent Builder API - DiagnosticReporter Service interface for Maven 4 plugins - DefaultDiagnosticReporter implementation with auto-discovery Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
force-pushed
the
feature/12571-build-report
branch
from
July 31, 2026 11:57
d7bb105 to
63da8ce
Compare
This was referenced Jul 31, 2026
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)