Skip to content

Console modes: --console=plain/rich/verbose/machine - #12697

Open
gnodet wants to merge 1 commit into
feature/build-reportfrom
feature/console-modes
Open

Console modes: --console=plain/rich/verbose/machine#12697
gnodet wants to merge 1 commit into
feature/build-reportfrom
feature/console-modes

Conversation

@gnodet

@gnodet gnodet commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Part 3 of the logging feature chain. Depends on #12695 (build report).

Adds the --console CLI 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 behavior
  • machine — JSON lines: one typed JSON object per lifecycle event, designed for piping to external tools

Auto-detection (--console=auto, the default): CI → plain, interactive TTY → rich, otherwise → verbose.

Files changed (16 files, ~4000 insertions)

Area Files
API Options.java (+console())
Event loggers PlainExecutionEventLogger, RichBuildEventListener, RichExecutionEventLogger, MachineBuildEventListener, MachineExecutionEventLogger
CLI wiring CommonsCliOptions, LayeredOptions, LookupInvoker (preliminary interactive detection), MavenInvoker (console mode switch + transfer listener)
Existing logger ExecutionEventLogger (version info on failure)
Tests 5 test classes with full coverage

PR chain

# PR Feature
1 #12694 Logging foundation
2 #12695 Build report
3 This PR Console modes
4 #12698 Warning mode + diagnostics
5 #12699 mvnlog viewer
6 #12702 Structured problems pipeline
7 #12714 TRACE level migration

Test plan

  • mvn test -pl impl/maven-cli — all 692 tests pass
  • mvn test -pl impl/maven-core — all tests pass
  • CI validation

🤖 Generated with Claude Code

@gnodet
gnodet force-pushed the feature/build-report branch from 602fffb to 056dcf0 Compare August 8, 2026 01:23
@gnodet
gnodet force-pushed the feature/console-modes branch from b0617f7 to 1a419b7 Compare August 8, 2026 01:23
gnodet added a commit that referenced this pull request Aug 8, 2026
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>
@gnodet
gnodet force-pushed the feature/console-modes branch from 1a419b7 to 1e4c616 Compare August 8, 2026 05:35
@gnodet
gnodet force-pushed the feature/build-report branch 2 times, most recently from a1ee585 to 0f31ce2 Compare August 8, 2026 12:14
@gnodet
gnodet force-pushed the feature/console-modes branch from 1e4c616 to eb4b145 Compare August 8, 2026 12:14
gnodet added a commit that referenced this pull request Aug 8, 2026
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>
@gnodet
gnodet force-pushed the feature/console-modes branch from eb4b145 to 35cf036 Compare August 8, 2026 19:17
gnodet added a commit that referenced this pull request Aug 8, 2026
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>
@gnodet
gnodet force-pushed the feature/build-report branch from 8083c89 to 170bd72 Compare August 8, 2026 19:35
@gnodet
gnodet force-pushed the feature/console-modes branch from 35cf036 to e06f638 Compare August 8, 2026 19:35
gnodet added a commit that referenced this pull request Aug 8, 2026
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>
@gnodet
gnodet force-pushed the feature/build-report branch from 170bd72 to af0cc72 Compare August 8, 2026 21:48
@gnodet
gnodet force-pushed the feature/console-modes branch from e06f638 to 77ddf3a Compare August 8, 2026 21:48
gnodet added a commit that referenced this pull request Aug 8, 2026
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
@gnodet
gnodet force-pushed the feature/console-modes branch from 77ddf3a to 6b6fc7f Compare August 9, 2026 08:11
@gnodet
gnodet force-pushed the feature/build-report branch from af0cc72 to 3658983 Compare August 9, 2026 08:11
@gnodet
gnodet marked this pull request as ready for review August 9, 2026 08:11

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 as color()). The @Experimental annotation means downstream breakage is acceptable.
  • JSON escaping in MachineBuildEventListener correctly 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++;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
completedProjects++;
completedProjects.incrementAndGet();

(with completedProjects changed to AtomicInteger at line 103)

* </li>
* </ol>
*/
String determineConsoleMode(MavenContext context) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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