Skip to content

[MNG-8450] Report BOM import warnings only at declaration sites - #12959

Merged
gnodet merged 3 commits into
apache:masterfrom
goutamadwant:fix/mng-8450-bom-warning-scope
Sep 1, 2026
Merged

gnodet merged 3 commits into
apache:masterfrom
goutamadwant:fix/mng-8450-bom-warning-scope

Conversation

@goutamadwant

Copy link
Copy Markdown
Contributor

Fixes #10179

Summary

Report conflicting BOM import warnings once at the model that declares the imports instead of repeating them for every inheriting child.

Implementation

  • Preserve each imported dependency-management source's declaration location.
  • Deduplicate warnings by declaration location and message within one top-level build.
  • Route warnings to the declaring reactor model's problem collector.
  • Use concurrent constant-time lookup for parallel model building.
  • Reset diagnostic state between top-level builds and during reactor-root fallback.
  • Preserve warnings from independent declarations and non-reactor parents.

Verification

  • mvn --batch-mode verify
  • Full maven-impl verification: 613 tests passed, 4 skipped
  • Focused model-builder verification: 27 tests passed
  • Coverage includes serial and parallel reactors, CI-friendly versions, child-activated parent profiles, repeated model-builder sessions, independent declarations, and non-reactor parents

Following this checklist to help us incorporate your contribution quickly and easily:

  • This pull request addresses one issue without unrelated changes.
  • The description explains what the change does, how, and why.
  • The commit has a meaningful subject and DCO sign-off.
  • Unit tests cover the behavioral changes.
  • mvn verify passes.
  • The Core IT suite has been run successfully.
  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
  • In any other case, please file an Apache Individual Contributor License Agreement.

Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
gnodet added a commit to gnodet/maven that referenced this pull request Aug 31, 2026

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Well-Designed Warning Deduplication

Solid fix for BOM import warning spam. The deduplication-by-declaration-site approach is clean, thread safety is correctly handled (ConcurrentHashMap.newKeySet() for dedup, ConcurrentHashMap for reactor collector lookup, CopyOnWriteArrayList/AtomicInteger/LongAdder in ProblemCollector.Impl), and state lifecycle is well-managed (deriveTopLevel() creates fresh dedup sets, loadFromRoot clears on reactor-root fallback).

Test coverage is thorough — serial and parallel builds, reactor and non-reactor parents, independent declarations, profile-activated imports, and repeated session builds.

Minor polish suggestions (non-blocking):

  1. Fully-qualified Collectors — DefaultModelBuilderTest.java uses java.util.stream.Collectors fully qualified in two places while java.util.stream.Stream is already imported. Adding the import would be consistent.

  2. Javadoc on ImportWarningKey — The new record at DefaultModelBuilder.java:684 would benefit from a brief comment explaining its role in deduplication.

  3. Dual-key rationale in registerReactorProblemCollector — source.getLocation() (path form) and source.getPath().toUri().toString() (URI form) are registered as two separate keys. The dual-key approach works as a safety net, but a brief comment explaining the rationale would help future maintainers.

  4. Anonymous collector extraction — The anonymous ModelProblemCollector in deduplicatingImportProblemCollector() delegates 7 methods. Consider extracting it as a named inner class for readability.

Note: The "Core IT suite has been run successfully" checkbox in the PR description is unchecked — maintainers may want confirmation before merging.

📋 PR Metadata

Aspect Current Suggested
Labels (none) enhancement
Milestone (none) 4.1.0

🔀 Backport Status

✅ Not needed — the V40 warning was introduced in Maven 4.0, so this fix correctly targets master only.

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

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet added this to the 4.0.0-rc-7 milestone Sep 1, 2026
@gnodet gnodet added the bug Something isn't working label Sep 1, 2026
@gnodet gnodet modified the milestones: 4.0.0-rc-7, 4.1.0 Sep 1, 2026
- Import java.util.stream.Collectors instead of using fully-qualified references
- Add Javadoc on ImportWarningKey record explaining its deduplication role
- Document dual-key rationale in registerReactorProblemCollector
- Extract anonymous ModelProblemCollector to named DeduplicatingImportProblemCollector inner class

Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added the enhancement New feature or request label Sep 1, 2026
@gnodet
gnodet merged commit 625d69d into apache:master Sep 1, 2026
22 checks passed
gnodet added a commit that referenced this pull request Sep 1, 2026
* [MNG-8450] Report BOM import warnings only at declaration sites

Signed-off-by: goutamadwant <workwithgoutam@gmail.com>

* [MNG-8450] Handle import warnings without source locations

Signed-off-by: goutamadwant <workwithgoutam@gmail.com>

* [MNG-8450] Address review feedback: polish deduplication code

- Import java.util.stream.Collectors instead of using fully-qualified references
- Add Javadoc on ImportWarningKey record explaining its deduplication role
- Document dual-key rationale in registerReactorProblemCollector
- Extract anonymous ModelProblemCollector to named DeduplicatingImportProblemCollector inner class

Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit that referenced this pull request Sep 1, 2026
…) (#13003)

* [MNG-8450] Report BOM import warnings only at declaration sites



* [MNG-8450] Handle import warnings without source locations



* [MNG-8450] Address review feedback: polish deduplication code

- Import java.util.stream.Collectors instead of using fully-qualified references
- Add Javadoc on ImportWarningKey record explaining its deduplication role
- Document dual-key rationale in registerReactorProblemCollector
- Extract anonymous ModelProblemCollector to named DeduplicatingImportProblemCollector inner class




---------

Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
Co-authored-by: Goutam Adwant <8672451+goutamadwant@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MNG-8450] BOM importing model building warnings should be reported in-situ

2 participants