Console modes: --console=plain/rich/verbose/machine - #12697
Conversation
602fffb to
056dcf0
Compare
b0617f7 to
1a419b7
Compare
Add --warning-mode CLI flag (summary/all/none/fail) for controlling how build warnings are displayed. Enrich BuilderProblem with key, suggestion, documentationUrl, INFO severity, and a builder API. Add DiagnosticReporter service and DefaultDiagnosticCollector for deduplication across parallel module builds. Part 4 of the #12572 split (depends on console modes PR #12697). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1a419b7 to
1e4c616
Compare
a1ee585 to
0f31ce2
Compare
1e4c616 to
eb4b145
Compare
Add --warning-mode CLI flag (summary/all/none/fail) for controlling how build warnings are displayed. Enrich BuilderProblem with key, suggestion, documentationUrl, INFO severity, and a builder API. Add DiagnosticReporter service and DefaultDiagnosticCollector for deduplication across parallel module builds. Part 4 of the #12572 split (depends on console modes PR #12697). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
eb4b145 to
35cf036
Compare
Add --warning-mode CLI flag (summary/all/none/fail) for controlling how build warnings are displayed. Enrich BuilderProblem with key, suggestion, documentationUrl, INFO severity, and a builder API. Add DiagnosticReporter service and DefaultDiagnosticCollector for deduplication across parallel module builds. Part 4 of the #12572 split (depends on console modes PR #12697). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8083c89 to
170bd72
Compare
35cf036 to
e06f638
Compare
Add --warning-mode CLI flag (summary/all/none/fail) for controlling how build warnings are displayed. Enrich BuilderProblem with key, suggestion, documentationUrl, INFO severity, and a builder API. Add DiagnosticReporter service and DefaultDiagnosticCollector for deduplication across parallel module builds. Part 4 of the #12572 split (depends on console modes PR #12697). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
170bd72 to
af0cc72
Compare
e06f638 to
77ddf3a
Compare
Add --warning-mode CLI flag (summary/all/none/fail) for controlling how build warnings are displayed. Enrich BuilderProblem with key, suggestion, documentationUrl, INFO severity, and a builder API. Add DiagnosticReporter service and DefaultDiagnosticCollector for deduplication across parallel module builds. Part 4 of the #12572 split (depends on console modes PR #12697). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- plain: compact one-line-per-module output, auto-selected in CI - rich: JLine status bar with live reactor progress, auto-selected on TTY - verbose: full mojo-level output, current Maven 4.0 default - machine: JSON lines, one typed JSON object per lifecycle event - Auto-detection: CI → plain, interactive TTY → rich, otherwise → verbose
77ddf3a to
6b6fc7f
Compare
af0cc72 to
3658983
Compare
gnodet
left a comment
There was a problem hiding this comment.
Well-structured PR adding four console modes with comprehensive test coverage (1317 lines of tests). Two issues found, one concurrency bug.
Also noted:
- The
Options.console()API addition follows the established pattern (Optional<String>, same ascolor()). The@Experimentalannotation means downstream breakage is acceptable. - JSON escaping in
MachineBuildEventListenercorrectly handles all RFC 8259 required escapes, with test coverage for edge cases. - Test coverage is strong: 5 new test classes covering all four console modes.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
| @Override | ||
| public void projectFinished(String projectId) { | ||
| activeProjects.remove(projectId); | ||
| completedProjects++; |
There was a problem hiding this comment.
Race condition: completedProjects++ is not atomic. The field is volatile int (line 103) but ++ is a non-atomic read-increment-write compound operation. In parallel builds (-T N), concurrent calls to projectFinished() from worker threads can lose increments, causing the progress counter to under-report.
The same class already uses AtomicInteger for warningCount and errorCount (lines 133-136).
| completedProjects++; | |
| completedProjects.incrementAndGet(); |
(with completedProjects changed to AtomicInteger at line 103)
| * </li> | ||
| * </ol> | ||
| */ | ||
| String determineConsoleMode(MavenContext context) { |
There was a problem hiding this comment.
Unrecognized --console values (including typos like --console=plian) silently fall through to auto-detection. This is inconsistent with the existing --color option in LookupInvoker.java (lines 274-276) which throws IllegalArgumentException for invalid values. Adding validation for consistency would help users catch configuration mistakes.
gnodet
left a comment
There was a problem hiding this comment.
Well-structured PR adding four console modes with comprehensive test coverage. Two concurrency issues found in RichBuildEventListener that affect parallel builds (-T flag):
Confirmed findings (verified independently):
-
[High — Concurrency bug]
RichBuildEventListener.java:308—completedProjects++on avolatile intis not atomic. In parallel builds, multiple threads callprojectFinished()concurrently, causing lost increments. The same class already usesAtomicIntegerforwarningCount(line 133) anderrorCount(line 136), and the companionMachineExecutionEventLoggerprotects its equivalent counter withsynchronized.completedProjectsshould useAtomicIntegeras well. -
[Medium — Logic issue in parallel builds]
RichBuildEventListener.java:635—projectOrder.indexOf(pid) < completedProjectsassumes modules complete in reactor order, which does not hold in parallel builds. Example: reactor order [A(0), B(1), C(2)] with B and C independent. If C completes before B starts,completedProjects=2, and B (index 1 < 2) would incorrectly show a green checkmark before it runs. Consider tracking completed project IDs in aSet<String>instead of relying on positional count. -
[Low — Style]
MachineExecutionEventLogger.java:96—session.getRequest().getGoals().stream().collect(Collectors.joining(" "))can be simplified toString.join(" ", session.getRequest().getGoals()), consistent with line 104 of the same file which already usesString.joinfor profiles.
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
| @Override | ||
| public void projectFinished(String projectId) { | ||
| activeProjects.remove(projectId); | ||
| completedProjects++; |
There was a problem hiding this comment.
[High — Concurrency bug] completedProjects++ on a volatile int is not atomic. In parallel builds (-T flag), multiple threads call projectFinished() concurrently, causing lost increments via the classic read-modify-write race.
This class already uses AtomicInteger for warningCount and errorCount. Suggest:
| completedProjects++; | |
| completedProjects.incrementAndGet(); |
(with the field declaration changed to private final AtomicInteger completedProjects = new AtomicInteger();)
| } else { | ||
| s.append(YELLOW).append("● ").append(RESET); | ||
| } | ||
| } else if (projectOrder.indexOf(pid) < completedProjects) { |
There was a problem hiding this comment.
[Medium — Logic issue in parallel builds] This assumes modules complete in reactor order, which is not guaranteed with -T. A module not yet started can have a lower reactor index than the count of completed modules, causing an incorrect green checkmark.
Consider tracking completed project IDs in a Set<String> and checking completedProjects.contains(pid) instead.
| currentVisitedProjectCount = allProjects.size() - projects.size(); | ||
| buildStartTime = MonotonicClock.now(); | ||
|
|
||
| String goals = session.getRequest().getGoals().stream().collect(Collectors.joining(" ")); |
There was a problem hiding this comment.
[Low — Style] This can be simplified to String.join(" ", session.getRequest().getGoals()), consistent with line 104 which already uses String.join for profiles.
| String goals = session.getRequest().getGoals().stream().collect(Collectors.joining(" ")); | |
| String goals = String.join(" ", session.getRequest().getGoals()); |
Summary
Part 3 of the logging feature chain. Depends on #12695 (build report).
Adds the
--consoleCLI flag with four output modes:plain— compact one-line-per-module output, ideal for CI (auto-selected in CI environments)rich— JLine status bar with live reactor progress (auto-selected on interactive TTYs)verbose— full mojo-level output, current Maven 4.0 default behaviormachine— JSON lines: one typed JSON object per lifecycle event, designed for piping to external toolsAuto-detection (
--console=auto, the default): CI → plain, interactive TTY → rich, otherwise → verbose.Files changed (16 files, ~4000 insertions)
Options.java(+console())PlainExecutionEventLogger,RichBuildEventListener,RichExecutionEventLogger,MachineBuildEventListener,MachineExecutionEventLoggerCommonsCliOptions,LayeredOptions,LookupInvoker(preliminary interactive detection),MavenInvoker(console mode switch + transfer listener)ExecutionEventLogger(version info on failure)PR chain
mvnlogviewerTest plan
mvn test -pl impl/maven-cli— all 692 tests passmvn test -pl impl/maven-core— all tests pass🤖 Generated with Claude Code