Repository navigation
Conversation
bae1db9 to
5a5af1e
Compare
602fffb to
056dcf0
Compare
Add the --console CLI flag with four output modes: - plain: compact one-line-per-module output for CI - rich: JLine status bar with live reactor progress - verbose: full mojo-level output (current default) - machine: JSON lines for piping to external tools Part 3 of the #12572 split (depends on build report PR #12695). Co-Authored-By: Claude Opus 4.6 <[email protected]>
056dcf0 to
a1ee585
Compare
e64db31 to
de8044a
Compare
a1ee585 to
0f31ce2
Compare
Add the --console CLI flag with four output modes: - plain: compact one-line-per-module output for CI - rich: JLine status bar with live reactor progress - verbose: full mojo-level output (current default) - machine: JSON lines for piping to external tools Part 3 of the #12572 split (depends on build report PR #12695). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add the --console CLI flag with four output modes: - plain: compact one-line-per-module output for CI - rich: JLine status bar with live reactor progress - verbose: full mojo-level output (current default) - machine: JSON lines for piping to external tools Part 3 of the #12572 split (depends on build report PR #12695). Co-Authored-By: Claude Opus 4.6 <[email protected]>
8083c89 to
170bd72
Compare
Add the --console CLI flag with four output modes: - plain: compact one-line-per-module output for CI - rich: JLine status bar with live reactor progress - verbose: full mojo-level output (current default) - machine: JSON lines for piping to external tools Part 3 of the #12572 split (depends on build report PR #12695). Co-Authored-By: Claude Opus 4.6 <[email protected]>
170bd72 to
af0cc72
Compare
Add the --console CLI flag with four output modes: - plain: compact one-line-per-module output for CI - rich: JLine status bar with live reactor progress - verbose: full mojo-level output (current default) - machine: JSON lines for piping to external tools Part 3 of the #12572 split (depends on build report PR #12695). Co-Authored-By: Claude Opus 4.6 <[email protected]>
8baa65a to
02ac855
Compare
af0cc72 to
3658983
Compare
gnodet
left a comment
There was a problem hiding this comment.
Well-designed build report feature with clean API/impl separation and comprehensive tests. A few issues noted below.
Also noted:
- The architecture is solid: clean API interfaces in maven-api-core, record-based implementations in maven-core, EventSpy pattern for automatic discovery, thread-based log routing for parallel-build safety, atomic file writes with symlink swap.
- The PR correctly depends on PR #12694 (logging foundation) — should not be merged until #12694 lands.
- No test for the
captureLogEventrouting logic (mojo-level vs module-level vs build-level buffers). This is the core routing mechanism and warrants at least one test exercising the dispatch.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
gnodet
left a comment
There was a problem hiding this comment.
Well-designed build report feature with clean API/impl separation, solid thread safety, and comprehensive tests. A few issues worth addressing:
Confirmed findings (verified independently):
-
[Medium]
BuildReportCollector.java— The Javadoc onMAX_LOG_EVENTS_PER_SCOPEstates "events are dropped and a truncation notice is appended," butcaptureLogEventsilently drops events without ever appending a truncation notice. Either implement the truncation notice (e.g., append a synthetic LogEvent like "... N events truncated") or correct the Javadoc to say events are silently dropped. -
[Low]
BuildReportJsonWriter.java— ThewriteNullableFieldmethod has an unusedboolean hasMoreparameter annotated with@SuppressWarnings("unused"). The parameter is never read and the method always emits a trailing comma regardless. Remove it to avoid confusion. -
[Low]
BuildReportJsonWriter.java—writeProblemusessb.lastIndexOf(",\n")to remove trailing commas (searches entire buffer backwards), whilewriteLogEventuses the dedicatedremoveTrailingCommahelper (checks only last two characters). UseremoveTrailingCommaconsistently — it's safer sincelastIndexOfcould theoretically match an earlier,\nif future refactors change field order.
This review was generated by an AI agent (Claude Code) and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
gnodet
left a comment
There was a problem hiding this comment.
Well-structured addition of a JSON build report feature with clean API design, good test coverage (17 tests), and defensive error handling. The zero-dependency JSON writer is appropriate for Maven's philosophy. A few design items:
Medium severity:
-
No opt-out mechanism (
BuildReportCollector.java): The collector is unconditionally active for every build — everymvninvocation writes a JSON file to disk with no system property to disable it. Consider adding-Dmaven.build.report.skip=truefor environments where this is undesirable (read-only filesystems, embedded invocations, CI runners). -
MojoSkipped events not handled (
BuildReportCollector.java):ExecutionEvent.Type.MojoSkipped(fired e.g. when a mojo requires online mode but Maven is offline) silently vanishes from the report. Inconsistent withProjectSkippedwhich IS handled. Skipped mojos should be tracked withBuildStatus.SKIPPED.
Low severity:
-
Failure timestamp inaccuracy (
BuildReportCollector.javaline 1110):failureTimestampis set toMonotonicClock.now()at report-assembly time, not at actual failure time. The mojo's timing data does capture the real timing — worth documenting in theFailureReport.timestamp()Javadoc. -
Inconsistent trailing comma removal (
BuildReportJsonWriter.java):writeProblemusessb.lastIndexOf(",\n")which searches backwards through the entire buffer, whilewriteLogEventuses the more robustremoveTrailingComma(sb)which checks only the end. Consider usingremoveTrailingCommaconsistently. -
Unused
hasMoreparameter (BuildReportJsonWriter.javaline 1553): Annotated@SuppressWarnings("unused")and never referenced. Either use it to control comma behavior or remove it. -
~70 lines of duplicated test helpers:
BuildReportCollectorTestandBuildReportIntegrationTestshare identicalcreateProject,createSession,createMojoExecution, andcreateEventmethods. Consider extracting to a shared test utility.
The API design (immutable interfaces in maven-api-core, record implementations in maven-core, @Experimental markers) follows Maven's established patterns. Thread safety approach is sound. The atomic file write + symlink pattern is well-implemented with proper fallbacks.
This review was generated by an AI agent (Claude Code) and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
3658983 to
c51ee87
Compare
02ac855 to
812a842
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review of commit 92a187fb — build report + BuildEnvironment (2026-09-21).
Substantial progress since the last review. Many long-standing findings are now resolved:
- ✅ Truncation notice Javadoc fixed —
MAX_LOG_EVENTS_PER_SCOPEnow correctly says "silently dropped" - ✅
writeNullableFielddeadhasMoreparameter removed - ✅
DefaultSession.buildEnvironment()now uses double-checked locking with avolatilefield — correctly cached - ✅
batchMode/noTransferProgressJavadoc updated — both fields are now in the "What is captured" list - ✅
sequenceNumber()Javadoc fixed — now says "or -1 if unavailable" instead of "always non-negative" - ✅
hasReportCapture()guard restored inDefaultLog.withMetadata()— StackWalker cost is gated - ✅
MojoSkippedhandled inBuildReportCollector - ✅
Session.buildEnvironment()Javadoc no longer claims "same object as in report"
One remaining issue in captureLogEvent — see inline comment.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
- Add reactor.mdo model to maven-api-core (ReactorConfig, Alias, PhaseInjection, ReactorExtension) - Fix reader-stax.vm template: handle String* flat associations correctly (avoid variable shadowing in generated parseXxx() methods) - Re-enable generated ReactorConfigStaxReader in maven-cli - Fold BuildEnvironment (PR apache#12695) into feature branch - Wire ReactorConfig through InvokerRequest -> MavenExecutionRequest -> BuildEnvironment -> Session API - Add MojoExecutionFilter with CoordinatePredicate / PhasePredicate - Add ArgumentTokenizer (quote-aware) for alias/option expansion - Add MavenParser: alias expansion, reactor.xml options merge - Null-guard getUserProperties() in DefaultLifecycleExecutionPlanCalculator
- Add reactor.mdo model to maven-api-core (ReactorConfig, Alias, PhaseInjection, ReactorExtension) - Fix reader-stax.vm template: handle String* flat associations correctly (avoid variable shadowing in generated parseXxx() methods) - Re-enable generated ReactorConfigStaxReader in maven-cli - Fold BuildEnvironment (PR apache#12695) into feature branch - Wire ReactorConfig through InvokerRequest -> MavenExecutionRequest -> BuildEnvironment -> Session API - Add MojoExecutionFilter with CoordinatePredicate / PhasePredicate - Add ArgumentTokenizer (quote-aware) for alias/option expansion - Add MavenParser: alias expansion, reactor.xml options merge - Null-guard getUserProperties() in DefaultLifecycleExecutionPlanCalculator
- Add reactor.mdo model to maven-api-core (ReactorConfig, Alias, PhaseInjection, ReactorExtension) - Fix reader-stax.vm template: handle String* flat associations correctly (avoid variable shadowing in generated parseXxx() methods) - Re-enable generated ReactorConfigStaxReader in maven-cli - Fold BuildEnvironment (PR apache#12695) into feature branch - Wire ReactorConfig through InvokerRequest -> MavenExecutionRequest -> BuildEnvironment -> Session API - Add MojoExecutionFilter with CoordinatePredicate / PhasePredicate - Add ArgumentTokenizer (quote-aware) for alias/option expansion - Add MavenParser: alias expansion, reactor.xml options merge - Null-guard getUserProperties() in DefaultLifecycleExecutionPlanCalculator
- Add reactor.mdo model to maven-api-core (ReactorConfig, Alias, PhaseInjection, ReactorExtension) - Fix reader-stax.vm template: handle String* flat associations correctly (avoid variable shadowing in generated parseXxx() methods) - Re-enable generated ReactorConfigStaxReader in maven-cli - Fold BuildEnvironment (PR apache#12695) into feature branch - Wire ReactorConfig through InvokerRequest -> MavenExecutionRequest -> BuildEnvironment -> Session API - Add MojoExecutionFilter with CoordinatePredicate / PhasePredicate - Add ArgumentTokenizer (quote-aware) for alias/option expansion - Add MavenParser: alias expansion, reactor.xml options merge - Null-guard getUserProperties() in DefaultLifecycleExecutionPlanCalculator
…filter Introduces two features that build on top of the logging foundation and structured build report (MNG-XXXXX / PR apache#12695): 1. reactor.xml — a single .mvn/reactor.xml file that consolidates CLI options (replaces .mvn/maven.config), core extensions (replaces .mvn/extensions.xml), named build aliases, and lifecycle phase injections. Legacy files continue to be read when reactor.xml is absent — full backwards compatibility is preserved. 2. Named build aliases — short names defined in reactor.xml that expand to a full argument list before any Maven processing starts. Expansion is non-recursive; flag-style aliases (--skip-tests) are supported; blank alias names are rejected at expansion time. 3. Lifecycle execution filter — a maven.lifecycle.filter user property that skips mojo executions matching a coordinate or phase predicate (e.g. phase(test),:maven-enforcer-plugin). Applied in MojoExecutor before each execution; skipped mojos fire a MojoSkipped event.
…filter Introduces two features that build on top of the logging foundation and structured build report (MNG-XXXXX / PR apache#12695): 1. reactor.xml — a single .mvn/reactor.xml file that consolidates CLI options (replaces .mvn/maven.config), core extensions (replaces .mvn/extensions.xml), named build aliases, and lifecycle phase injections. Legacy files continue to be read when reactor.xml is absent — full backwards compatibility is preserved. 2. Named build aliases — short names defined in reactor.xml that expand to a full argument list before any Maven processing starts. Expansion is non-recursive; flag-style aliases (--skip-tests) are supported; blank alias names are rejected at expansion time. 3. Lifecycle execution filter — a maven.lifecycle.filter user property that skips mojo executions matching a coordinate or phase predicate (e.g. phase(test),:maven-enforcer-plugin). Applied in MojoExecutor before each execution; skipped mojos fire a MojoSkipped event.
…filter Introduces two features that build on top of the logging foundation and structured build report (MNG-XXXXX / PR apache#12695): 1. reactor.xml — a single .mvn/reactor.xml file that consolidates CLI options (replaces .mvn/maven.config), core extensions (replaces .mvn/extensions.xml), named build aliases, and lifecycle phase injections. Legacy files continue to be read when reactor.xml is absent — full backwards compatibility is preserved. 2. Named build aliases — short names defined in reactor.xml that expand to a full argument list before any Maven processing starts. Expansion is non-recursive; flag-style aliases (--skip-tests) are supported; blank alias names are rejected at expansion time. 3. Lifecycle execution filter — a maven.lifecycle.filter user property that skips mojo executions matching a coordinate or phase predicate (e.g. phase(test),:maven-enforcer-plugin). Applied in MojoExecutor before each execution; skipped mojos fire a MojoSkipped event.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review of commit 7d7854b2 — Javadoc addition to MavenJulHandler.LOGGER_CACHE.
New commit (7d7854b2) is clean: The added Javadoc clarifies that LOGGER_CACHE is intentionally unbounded, bounded in practice by the number of distinct JUL logger names, and grows monotonically in long-running daemon processes. This is accurate and appropriate.
One finding remains unaddressed (raised in prior review of 92a187fb): see inline comment.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-reviewing after the latest commits — this is a clean pass.
The ThreadLocal elimination is well-executed. Passing BuildEventListener and MessageBuilderFactory as inline parameters throughout the lifecycle callbacks is the right architectural move — ThreadLocals for lifecycle context are a code smell (hidden state, tricky in tests, painful in custom embedders).
The log capture machinery in DefaultBuildEventListener is correct. A potential TOCTOU concern on the size() < MAX && add() compound check in mojoLogBuffers / moduleLogBuffers was examined carefully — it is a false alarm. Because currentMojoByThread and currentProjectByThread are keyed by Thread.currentThread().getId(), each mojo/module buffer is exclusively accessed by a single thread: the thread that registered its key. No external synchronization is needed for those buffers. The contrast with buildLogBuffer (which correctly uses synchronized) is sound — that buffer is shared across threads (reactor startup/shutdown paths).
One minor documentation suggestion: a brief comment at the size() < MAX && add() check (line ~316) noting the single-thread-per-buffer invariant would help future readers not re-analyze this.
All new code is well-covered by tests. The API changes are appropriate for unreleased 4.1.0.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Introduce BuildEnvironment as a v4 API type on Session, providing a structured, immutable snapshot of the build invocation context: goals, user properties (with sensitive values redacted), curated system info, profiles, project selection, offline/batch flags, and concurrency settings. Available via Session.buildEnvironment() for plugins and extensions that need to inspect the build configuration programmatically. Related: #13460 (v3→v4 API migration) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…enhancements Structured LogEvent (maven-api-core, maven-core): - LogEvent / LogLevel API for structured log event representation - Source metadata: sourceClassName(), sourceMethodName(), threadId() - Execution context: projectId() and mojoId() Custom JUL Handler (maven-logging): - MavenJulHandler replaces SLF4JBridgeHandler — all JUL events route through SLF4J for consistent formatting regardless of origin - JUL metadata flows as method parameters via logDirect() instead of ThreadLocals - Re-entrancy guard for JLine StyleResolver → JUL → SLF4J bootstrap cycle Direct logging path (maven-logging, maven-core): - MavenSimpleLogger.logDirect() bypasses the SLF4J call chain for Log API and JUL events, carrying source metadata as parameters - MavenBaseLogger.formatLogPrefix() extracted as shared formatting logic - Eliminates ThreadLocal round-trips, lambda allocations, and SLF4J dispatch overhead for Maven-controlled logging paths Capability-driven optimization (maven-logging): - LogSink.needsFormattedMessage() — skip formatting when consumer uses structured fields (e.g. machine/JSON output mode) - LogSink.needsMetadata() — skip StackWalker and SourceMetadata allocation when consumer doesn't read source info (plain/rich console modes) - ProjectBuildLogAppender wires flags: metadata auto-enabled when reportCapture is active Structured LogSink (maven-logging, maven-core): - MavenSimpleLogger.LogSink replaces Consumer<String> with structured callback including level, logger name, clean message, and metadata - ProjectBuildLogAppender produces LogEvent objects with source metadata - BuildEventListener.projectLogMessage() now takes LogEvent Log API metadata (maven-core): - DefaultLog resolves caller class/method via StackWalker, gated behind LogSink.needsMetadata() for zero overhead in plain/rich console modes Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add "reportVersion": "1.0" as the first field in the JSON output so external consumers can detect format changes. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my prior review (approved at 690d8a84). The new commit (4d4ccfbde8f7) adds reportVersion() — two issues.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Expose optional trace and span identifiers for module and mojo reports. Capture tracing context from the SLF4J MDC at lifecycle start events and include it in JSON build reports. Bump the additive report schema version and cover both populated and absent correlation fields in tests.
| * @return the matching module report, or empty if not found | ||
| */ | ||
| @Nonnull | ||
| default Optional<ModuleReport> findModule(String moduleId) { |
There was a problem hiding this comment.
I'm personally very happy with it but shouldn't it be findSubProject now? 🤔
| * @return the error message, never {@code null} | ||
| */ | ||
| @Nonnull | ||
| String message(); |
There was a problem hiding this comment.
why not keeping the exception there?
| * @since 4.1.0 | ||
| */ | ||
| @Nullable | ||
| String traceId(); |
There was a problem hiding this comment.
i'd create a TracingContext wrapper or alike with traceid+spanId+parentSpanId
also not sure we must use String for these values since often they can be stored as long so maybe Object or alike
| * stable across Maven versions — field order is fixed, and new fields are | ||
| * appended at the end of each object. | ||
| */ | ||
| final class BuildReportJsonWriter { |
There was a problem hiding this comment.
i'd avoid the strinbuilder totally and pass directly the outputstream/writer, no need to have it in mem at all
| /** | ||
| * Internal immutable implementation of {@link ModuleReport}. | ||
| */ | ||
| record DefaultModuleReport( |
There was a problem hiding this comment.
think we can make mojos/output read only at instantiation time so no need of overrides (same for most records)
Why
Maven builds currently produce only console output — there is no machine-readable artifact capturing the result of a build. Tools (CI systems, IDEs, LLM agents) that need to know what succeeded, what failed, how long each module took, or what warnings were emitted must parse raw log text, which is fragile and tightly coupled to Maven's output format.
What
Introduces a structured JSON build report written to
target/build-report-<timestamp>.json(with abuild-report-latest.jsonsymlink) at the end of every build. The report captures:SUCCESS/FAILURE/SKIPPED), duration, start time, Maven and Java versions, goalsModuleReport): status, timing, per-mojo execution results (MojoReport)LogEvent) with level, timestamp, logger name, source class/method, and thread ID — partitioned so thatBuildReport.output(),ModuleReport.output(), andMojoReport.output()form a non-overlapping partition of the full build logBuilderProblem) with deduplication key, suggestion, and documentation URLNew public API in
maven-api-core(@Experimental):org.apache.maven.api.build.report:BuildReport,ModuleReport,MojoReport,FailureReport,LogEvent,LogLevel,BuildStatusAlso promotes
Log.trace()/Log.isTraceEnabled()/Log.child()fromdefault-with-no-op to abstract methods, since the logging foundation (built in #12694) now provides full implementations.How
BuildReportCollector— a@Named @Singleton EventSpythat hooks into the build lifecycle viaAbstractEventSpy. No wiring changes needed; it is discovered automatically by the DI container.ConcurrentHashMap<threadId → scope key>tracks which mojo or module is executing on each thread, so log events from parallel builds are attributed to the correct scope.--console=machinemode addsMachineBuildEventListener+MachineExecutionEventLogger, which emit one JSON object per line (JSON lines) to stdout — designed for real-time consumption by external tools.ExecutionEventLoggeris simplified: the grouped reactor summary (failures first, then successes) is replaced with a linear in-order summary that prints...for skipped modules; failure/success lines are both emitted at INFO level with ANSI colour applied by the message builder. Maven and Java version are printed on failure to aid bug reports (MNG-7372).Files.move) to prevent partial reads.jul-to-slf4jandlogback-classicoptional dependencies are removed fromapache-mavenandimpl/maven-cli— the native JUL handler introduced in Logging foundation: structured LogEvent, JUL handler, Log API enhancements #12694 replaces the bridge.PR chain
mvnlogviewer