Skip to content

Warning mode, diagnostic collector, BuilderProblem enrichments - #12698

Open
gnodet wants to merge 1 commit into
feature/console-modesfrom
feature/warning-mode
Open

Warning mode, diagnostic collector, BuilderProblem enrichments#12698
gnodet wants to merge 1 commit into
feature/console-modesfrom
feature/warning-mode

Conversation

@gnodet

@gnodet gnodet commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Part 4 of the logging feature chain. Depends on #12697 (console modes).

Adds --warning-mode CLI flag and structured diagnostic infrastructure:

  • --warning-mode=summary (default) — deduplicated warning summary at end of build
  • --warning-mode=all — inline warnings + summary
  • --warning-mode=none — suppress diagnostic summary
  • --warning-mode=fail — treat warnings as build errors

BuilderProblem API enrichments

  • getKey() — stable deduplication key for cross-module dedup
  • getSuggestion() — actionable fix suggestion
  • getDocumentationUrl() — link to relevant docs
  • INFO severity level added to Severity enum
  • BuilderProblem.builder() — fluent builder API with DefaultProblem record

New service API

  • DiagnosticReporter@Inject-able service for plugins to report structured problems

Internal infrastructure

  • DefaultDiagnosticCollector — thread-safe, deduplicating problem store with suppression support
  • DefaultDiagnosticReporter / DefaultDiagnosticSummary — wiring
  • BuildReportCollector upgraded to use DefaultDiagnosticCollector, auto-collect WARN log events, print summary

Files changed (16 files, ~1600 insertions)

Area Files
API BuilderProblem enrichments, DiagnosticReporter, Options (+warningMode())
CLI wiring CommonsCliOptions, LayeredOptions, MavenInvoker
Collector BuildReportCollector (full diagnostic integration), BuildReportJsonWriter (problem enrichments)
Internal DefaultDiagnosticCollector, DefaultDiagnosticReporter, DefaultDiagnosticSummary
Impl DefaultBuilderProblem (key/suggestion/url fields)
Tests 4 test classes updated + 1 new (DefaultDiagnosticCollectorTest)

PR chain

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

Test plan

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

🤖 Generated with Claude Code

@gnodet
gnodet force-pushed the feature/console-modes branch from b0617f7 to 1a419b7 Compare August 8, 2026 01:23
@gnodet
gnodet force-pushed the feature/warning-mode branch from 0cc76eb to 6124231 Compare August 8, 2026 01:23
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the mvnlog tool for viewing and analyzing build-report JSON files.
Includes BuildReportRenderer for human-readable output, SimpleJsonReader
for dependency-free JSON parsing, shell scripts (mvnlog/mvnlog.cmd),
and --log routing in mvn/mvn.cmd. Also adds integration tests for
build report generation, console modes, and the mvnlog viewer, plus
--console=verbose flags for ITs that depend on verbose output.

Part 5 of the #12572 split (depends on warning mode PR #12698).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the mvnlog tool for viewing and analyzing build-report JSON files.
Includes BuildReportRenderer for human-readable output, SimpleJsonReader
for dependency-free JSON parsing, shell scripts (mvnlog/mvnlog.cmd),
and --log routing in mvn/mvn.cmd. Also adds integration tests for
build report generation, console modes, and the mvnlog viewer, plus
--console=verbose flags for ITs that depend on verbose output.

Part 5 of the #12572 split (depends on warning mode PR #12698).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the feature/warning-mode branch from 6124231 to dc3bccd Compare August 8, 2026 05:35
@gnodet
gnodet force-pushed the feature/console-modes branch 2 times, most recently from 1e4c616 to eb4b145 Compare August 8, 2026 12:14
@gnodet
gnodet force-pushed the feature/warning-mode branch from dc3bccd to a7c83db Compare August 8, 2026 12:14
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the mvnlog tool for viewing and analyzing build-report JSON files.
Includes BuildReportRenderer for human-readable output, SimpleJsonReader
for dependency-free JSON parsing, shell scripts (mvnlog/mvnlog.cmd),
and --log routing in mvn/mvn.cmd. Also adds integration tests for
build report generation, console modes, and the mvnlog viewer, plus
--console=verbose flags for ITs that depend on verbose output.

Part 5 of the #12572 split (depends on warning mode PR #12698).

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
gnodet force-pushed the feature/warning-mode branch from a7c83db to 7243fd7 Compare August 8, 2026 19:17
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the mvnlog tool for viewing and analyzing build-report JSON files.
Includes BuildReportRenderer for human-readable output, SimpleJsonReader
for dependency-free JSON parsing, shell scripts (mvnlog/mvnlog.cmd),
and --log routing in mvn/mvn.cmd. Also adds integration tests for
build report generation, console modes, and the mvnlog viewer, plus
--console=verbose flags for ITs that depend on verbose output.

Part 5 of the #12572 split (depends on warning mode PR #12698).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the feature/console-modes branch from 35cf036 to e06f638 Compare August 8, 2026 19:35
@gnodet
gnodet force-pushed the feature/warning-mode branch from 7243fd7 to af945c2 Compare August 8, 2026 19:35
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the mvnlog tool for viewing and analyzing build-report JSON files.
Includes BuildReportRenderer for human-readable output, SimpleJsonReader
for dependency-free JSON parsing, shell scripts (mvnlog/mvnlog.cmd),
and --log routing in mvn/mvn.cmd. Also adds integration tests for
build report generation, console modes, and the mvnlog viewer, plus
--console=verbose flags for ITs that depend on verbose output.

Part 5 of the #12572 split (depends on warning mode PR #12698).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the feature/console-modes branch from e06f638 to 77ddf3a Compare August 8, 2026 21:48
@gnodet
gnodet force-pushed the feature/warning-mode branch from af945c2 to 850a04c Compare August 8, 2026 21:48
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the mvnlog tool for viewing and analyzing build-report JSON files.
Includes BuildReportRenderer for human-readable output, SimpleJsonReader
for dependency-free JSON parsing, shell scripts (mvnlog/mvnlog.cmd),
and --log routing in mvn/mvn.cmd. Also adds integration tests for
build report generation, console modes, and the mvnlog viewer, plus
--console=verbose flags for ITs that depend on verbose output.

Part 5 of the #12572 split (depends on warning mode PR #12698).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the mvnlog tool for viewing and analyzing build-report JSON files.
Includes BuildReportRenderer for human-readable output, SimpleJsonReader
for dependency-free JSON parsing, shell scripts (mvnlog/mvnlog.cmd),
and --log routing in mvn/mvn.cmd. Also adds integration tests for
build report generation, console modes, and the mvnlog viewer, plus
--console=verbose flags for ITs that depend on verbose output.

Part 5 of the #12572 split (depends on warning mode PR #12698).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- --warning-mode=summary|all|none|fail CLI flag
- BuilderProblem enrichments: getKey(), getSuggestion(), getDocumentationUrl()
- INFO severity level added to BuilderProblem.Severity enum
- DiagnosticReporter injectable service for plugins to report structured problems
- DefaultDiagnosticCollector: thread-safe, deduplicating problem store
- BuildReportCollector upgraded with full diagnostic integration
@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/warning-mode branch from 850a04c to 5913a2b 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 diagnostic infrastructure with good test coverage. Two issues found after verification (a third finding about removed try-catch was a false positive — EventSpyDispatcher.onEvent() already provides the safety net).

Also noted:

  • Two independent BuilderProblem implementations exist (private DefaultProblem record in Builder and public DefaultBuilderProblem in impl). Future field additions need to update both.
  • The warningMode propagation via user properties (maven.build.warningMode) is pragmatic for an EventSpy but worth noting as a side-channel.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

String key = problem.getKey();

// Problems without a key get a synthetic key for storage
if (key == null) {

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: noKeyCounter.increment() and noKeyCounter.longValue() are not atomic together. Two concurrent threads reporting null-key problems can both get the same counter value, producing the same synthetic key "__no_key__N", and the second problem is silently dropped by putIfAbsent.

Fix: use AtomicLong instead of LongAdder with incrementAndGet() for an atomic unique counter:

Suggested change
if (key == null) {
key = "__no_key__" + noKeyCounter.incrementAndGet();

(also change noKeyCounter field type from LongAdder to AtomicLong)

.get());
options.addOption(Option.builder()
.longOpt(WARNING_MODE)
.hasArg()

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.

No validation of --warning-mode values. An invalid value like --warning-mode=quiet is silently accepted and defaults to summary behavior. BaseParser.validate() already validates --color and --fail-on-severity against allowed values — --warning-mode should follow the same pattern for consistency.

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