Skip to content

Build report, console modes, and warning control - #12572

Draft
gnodet wants to merge 2 commits into
masterfrom
feature/12571-build-report
Draft

Build report, console modes, and warning control#12572
gnodet wants to merge 2 commits into
masterfrom
feature/12571-build-report

Conversation

@gnodet

@gnodet gnodet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Build Report Foundation

What users see

--console=plain — compact CI output (default when CI=true)

One line per completed module, no ANSI, no status bar. Auto-selected on CI (CI=true, JENKINS_URL, etc.):

$ mvn validate --console=plain
[INFO] Apache Maven [1/38] ................................ SUCCESS [  0.539 s]
[INFO] Maven 4 API [2/38] ................................. SUCCESS [  0.017 s]
[INFO] Maven 4 API :: Meta annotations [3/38] ............. SUCCESS [  0.019 s]
[INFO] Maven 4 API :: Dependency Injection [4/38] ......... SUCCESS [  0.018 s]
[INFO] Maven 4 API :: XML [5/38] .......................... SUCCESS [  0.027 s]
[INFO] Maven 4 API :: Model [6/38] ........................ SUCCESS [  0.070 s]
...
[INFO] Maven 4 CLI [35/38] ................................ SUCCESS [  0.240 s]
[INFO] Maven Plugin Testing Mechanism [36/38] ............. SUCCESS [  0.162 s]
[INFO] Maven Embedder (deprecated) [37/38] ................ SUCCESS [  0.178 s]
[INFO] Apache Maven Distribution [38/38] .................. SUCCESS [  0.514 s]
[INFO]
[INFO] BUILD SUCCESS
[INFO] 38 modules | 38 passed
[INFO] Total time:  5.519 s
[INFO] Full report: target/build-reports/build-report-latest.json

--console=rich — live status bar (default on interactive TTY)

During the build, the bottom of the terminal shows a live JLine status area that updates in place. All plugin INFO/WARN output is suppressed — only ERRORs scroll above the status bar:

 Maven 4.1.0-SNAPSHOT ─ building Apache Maven 4.1.0-SNAPSHOT
 ● maven-core  maven-compiler-plugin:compile  8s
 ● maven-api-core  maven-surefire-plugin:test  3s
────────────────────────────────────────────────────────────────────
 ✓ ✓ ✓ ● ● ○ ○ ○ ○ ○ [5/10]  32s  ↓ core-4.1.0.jar 256KB/512KB

With large reactors (where per-module indicators don't fit), the separator becomes a proportional progress bar:

 Maven 4.1.0-SNAPSHOT ─ building Apache Camel 4.22.0-SNAPSHOT
 ● camel-jaxb  flatten-maven-plugin:flatten  0s
 ● camel-core  maven-compiler-plugin:compile  8s
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━────────────────────────────────────── [77/673]  1m 18s

At the end, the status bar is torn down and replaced with a compact summary:

BUILD SUCCESS
38 modules | 38 passed
Total time:  5.772 s
Full report: target/build-reports/build-report-latest.json

When diagnostics are present:

BUILD SUCCESS
38 modules | 38 passed
Diagnostics: 3 warnings — run mvnlog to see details
Total time:  32.1s
Full report: target/build-reports/build-report-latest.json

--console=machine — JSON lines for tools and LLM agents

One JSON object per line, designed for piping to jq, IDE integrations, and AI agents:

$ mvn validate --console=machine
{"event":"build.started","timestamp":"...","projectCount":38,"goals":"validate","profiles":"signing-key"}
{"event":"module.started","timestamp":"...","module":"Apache Maven","groupId":"org.apache.maven","artifactId":"maven","version":"4.1.0-SNAPSHOT","index":1,"total":38}
{"event":"mojo.started","timestamp":"...","module":"Apache Maven","plugin":"maven-enforcer-plugin","goal":"enforce","phase":"validate","executionId":"enforce-bytecode-version"}
{"event":"log","timestamp":"...","level":"INFO","module":"maven","logger":"...","message":"Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed"}
{"event":"mojo.succeeded","timestamp":"...","module":"Apache Maven","plugin":"maven-enforcer-plugin","goal":"enforce","duration":0.33}
{"event":"module.succeeded","timestamp":"...","module":"Apache Maven","duration":0.543}
...
{"event":"build.finished","timestamp":"...","status":"SUCCESS","duration":4.363,"total":38,"passed":38,"failed":0,"skipped":0}

--console=verbose — full output (Maven 4.0 default)

Unchanged from today's Maven 4.0 behavior — all per-mojo banners, plugin output, download progress:

$ mvn validate --console=verbose
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Apache Maven                                                       [pom]
[INFO] Maven 4 API                                                        [pom]
[INFO] Maven 4 API :: Meta annotations                                    [jar]
...
[INFO] -----------------------< org.apache.maven:maven >-----------------------
[INFO] Building Apache Maven 4.1.0-SNAPSHOT                              [1/38]
[INFO]   from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- enforcer:3.6.3:enforce (enforce-bytecode-version) @ maven ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.447 s
[INFO] Finished at: 2026-08-06T07:58:06+02:00
[INFO] ------------------------------------------------------------------------

--console=auto (the default)

Selects automatically: CI=true or JENKINS_URL set → plain; interactive TTY → rich; otherwise → verbose.

Warning summary at end of build

All console modes show a deduplicated warning summary at end of build (unless --warning-mode=none):

[WARNING] ┌──────────────────────────────────────────────────────────────────────┐
[WARNING] │ Build validation completed with 3 warning(s):                       │
[WARNING] ├──────────────────────────────────────────────────────────────────────┤
[WARNING] │ [WARNING] 'version' contains an expression but should be a          │
[WARNING] │  constant. maven-api-core:4.1.0-SNAPSHOT  ×3                        │
[WARNING] │ [WARNING] 'build.plugins.plugin.version' for                        │
[WARNING] │  org.apache.maven.plugins:maven-surefire-plugin is missing. ×1      │
[WARNING] └──────────────────────────────────────────────────────────────────────┘

--warning-mode controls behavior:

Mode During build End of build Exit code
all (default) show warnings show summary 0
summary suppress inline show summary 0
none suppress all suppress all 0
fail show warnings show summary 1 (if any warning)

Version info on failure

When the build fails, Maven and Java version are printed to help with bug reports:

BUILD FAILURE
38 modules | 31 passed | 1 failed | 6 skipped
Total time:  32.1s
Maven:       4.1.0-SNAPSHOT
Java:        21.0.11 (Eclipse Adoptium)
Full report: target/build-reports/build-report-latest.json

Structured build report JSON

Every build writes target/build-reports/build-report-latest.json:

{
  "formatVersion": 1,
  "status": "SUCCESS",
  "duration": "PT5.535S",
  "startTime": "2026-08-06T05:58:15.816Z",
  "mavenVersion": "4.1.0-SNAPSHOT",
  "javaVersion": "21.0.11",
  "goals": ["validate"],
  "project": "org.apache.maven:maven:4.1.0-SNAPSHOT",
  "multiModule": true,
  "threads": 1,
  "modules": [
    {
      "groupId": "org.apache.maven",
      "artifactId": "maven",
      "version": "4.1.0-SNAPSHOT",
      "status": "SUCCESS",
      "duration": "PT0.577S",
      "mojos": [
        {
          "plugin": "maven-enforcer-plugin",
          "goal": "enforce",
          "phase": "validate",
          "status": "SUCCESS",
          "duration": "PT0.346S",
          "output": [...]
        }
      ]
    }
  ]
}

mvnlog — build report viewer

After a build completes, mvnlog reads the report JSON and renders a human-readable view:

$ mvnlog                    # view latest build report
$ mvnlog warnings           # just the deduplicated warnings
$ mvnlog module core        # output from a specific module
$ mvnlog --json             # raw JSON output for tools

How it works

Console mode architecture

Each console mode is a pair of cooperating classes:

Mode BuildEventListener ExecutionListener
rich RichBuildEventListener (JLine status bar) RichExecutionEventLogger (suppress per-mojo banners)
plain PlainBuildEventListener (no-op status) PlainExecutionEventLogger (one line per module)
machine MachineBuildEventListener (JSON log/transfer events) MachineExecutionEventLogger (JSON lifecycle events)
verbose existing SimpleBuildEventListener existing ExecutionEventLogger

The BuildEventListener handles real-time events (log messages, transfer progress), while the ExecutionListener handles lifecycle events (session/project/mojo start/finish).

Build report pipeline

  1. BuildReportCollector — injected ExecutionListener that captures every lifecycle event, mojo execution, and log message into an in-memory report
  2. BuildReportWriter — writes the report to target/build-reports/build-report-latest.json at session end
  3. BuilderProblem — universal diagnostic currency: model validation warnings, plugin validation, and (with PR Fix #12643: Pipe structured BuilderProblems into DiagnosticCollector #12647) plugin-reported diagnostics all flow through BuilderProblem into DiagnosticCollector

Warning deduplication

Warnings are deduplicated by key (e.g. pom:version-expression) and counted. The end-of-build summary shows each unique warning with its count, regardless of how many modules triggered it.

DiagnosticReporter (PR #12647)

A new Maven 4 API service that plugins can inject to report structured diagnostics:


Follow-up PRs

@gnodet gnodet changed the title Fix #12571: Add structured build report (Phase 0) Fix #12571: Build output overhaul — structured report, console modes, warning control Jul 29, 2026
@gnodet gnodet changed the title Fix #12571: Build output overhaul — structured report, console modes, warning control Fix #12571: Build Report Foundation — structured report, console modes, warning control Jul 29, 2026
@gnodet
gnodet force-pushed the feature/12571-build-report branch 6 times, most recently from 3192bb4 to 87be78e Compare July 29, 2026 14:59
@gnodet gnodet changed the title Fix #12571: Build Report Foundation — structured report, console modes, warning control Build Report Foundation — structured report, console modes, warning control Jul 29, 2026
@gnodet gnodet added this to the 4.1.0 milestone Jul 30, 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
gnodet force-pushed the feature/12571-build-report branch from d7bb105 to 63da8ce Compare July 31, 2026 11:57
gnodet added a commit that referenced this pull request Aug 4, 2026
Port and modernize the incremental build context from PR #1118,
building on the original Sonatype plexus-build-api / Takari
incrementalbuild work.

API (maven-api-core):
- BuildContext: register inputs, check status, associate
  outputs, skip execution, automatic stale output cleanup
- SPI: Workspace (NORMAL/ESCALATED/SUPPRESSED),
  CommittableBuildContext, BuildContextEnvironment,
  BuildContextFinalizer
- Diagnostic messages are NOT part of this API — use
  DiagnosticReporter from the build report API instead

Implementation (maven-impl):
- DefaultBuildContext with timestamp/size change detection
- State serialization for cross-build persistence
- PathMatcherFactory integration for Ant-style patterns
- 36 tests

Maven integration (maven-core):
- MojoExecutionScoped DI wiring
- ClasspathDigester + MojoConfigurationDigester for automatic
  configuration change detection
- MavenBuildContextFinalizer for post-mojo commit
- maven.buildcontext.skip property to disable entirely
- Performance: released-artifact digest bypass, no-op state skip,
  single-syscall file status, field reflection cache

Based on #12572 (Build Report Foundation).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the reactor has more modules than fit as individual ✓/●/○
indicators on the terminal width, switch to a full-width proportional
progress bar: green ━ for completed, yellow ━ for active, dim ─ for
remaining, with the counter and elapsed time appended.

The progress bar replaces the separator line — one line instead of
two (no redundant horizontal rule above the bar). This also gives
an extra project slot line to the status area.

Small reactors (≤ maxIndicators) keep the per-module indicators
with the separate separator line, where each module gets its own
symbol.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the feature/12571-build-report branch from 83ce6ac to 6fd5983 Compare August 4, 2026 22:33
@gnodet gnodet changed the title Build Report Foundation — structured report, console modes, warning control Build report, console modes, and warning control Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant