gnodet opened a new pull request, #12572:
URL: https://github.com/apache/maven/pull/12572
## Summary
Phase 0 of the build output overhaul (#12571): structured `BuildReport` data
model + JSON persistence.
- **API** (`maven-api-core`): `BuildReport`, `ModuleReport`, `MojoReport`,
`FailureReport`, `BuildStatus` — interfaces in `org.apache.maven.api.build`
- **Collector** (`maven-core`): `BuildReportCollector` — an `EventSpy` (same
pattern as `DefaultPluginValidationManager`) that collects lifecycle events
during the build
- **JSON writer** (`maven-core`): `BuildReportJsonWriter` — dependency-free
JSON serializer that writes `target/build-report.json` at session end
- **Tests**: 11 tests covering JSON serialization, report assembly, file
persistence, multi-module builds, failure tracking, and null handling
### What the report captures
```json
{
"formatVersion": 1,
"status": "SUCCESS",
"duration": "PT30S",
"startTime": "2025-01-15T10:30:00Z",
"mavenVersion": "4.1.0-SNAPSHOT",
"javaVersion": "21.0.1",
"goals": ["clean", "install"],
"project": "org.apache.maven:maven:4.1.0-SNAPSHOT",
"multiModule": true,
"threads": 4,
"modules": [{
"groupId": "org.apache.maven",
"artifactId": "maven-core",
"version": "4.1.0-SNAPSHOT",
"status": "SUCCESS",
"duration": "PT12.345S",
"mojos": [{
"groupId": "org.apache.maven.plugins",
"artifactId": "maven-compiler-plugin",
"version": "3.15.0",
"goal": "compile",
"executionId": "default-compile",
"phase": "compile",
"status": "SUCCESS",
"duration": "PT2.1S"
}]
}],
"failures": []
}
```
### Design decisions
- **No new dependencies** — JSON is hand-written (`BuildReportJsonWriter`),
avoiding a Jackson/Gson dependency in maven-core
- **EventSpy pattern** — `BuildReportCollector` extends `AbstractEventSpy`
and is auto-discovered by DI, same as `DefaultPluginValidationManager`
- **Thread-safe** — `ConcurrentHashMap` + synchronized lists for parallel
builds (`-T`)
- **Format version** — `formatVersion: 1` for forward compatibility;
consumers check this before parsing
- **No console output changes** — Phase 0 is invisible to users; the report
is silently written alongside the build
### What's next (future PRs)
- **Phase 1**: `DiagnosticCollector` service + warning summary at end of
build
- **Phase 2**: CI mode (`--console=plain`) + batch output improvements
- **Phase 3**: Smart terminal with JLine `Display` (status bar like mvnd)
- **Phase 4**: Machine-readable output (`--console=machine`)
## Test plan
- [x] `BuildReportJsonWriterTest` — 7 tests: JSON structure, escaping, null
handling, multiple modules
- [x] `BuildReportCollectorTest` — 4 tests: report assembly, failure
tracking, file persistence, multi-module
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]