[MNG-6797] Remember if Maven model problems were encountered in Maven 4 - #12620
[MNG-6797] Remember if Maven model problems were encountered in Maven 4#12620wilx wants to merge 2 commits into
Conversation
Retain reactor-discovery model problems in the Maven 4 session and expose the state through both the native and legacy session APIs. Preserve collection-strategy compatibility and ignore problems from discarded discovery attempts. Fixes apache#8485.
992accf to
1edef52
Compare
gnodet
left a comment
There was a problem hiding this comment.
Well-structured port of the model-problem retention feature from Maven 3 to Maven 4 with thorough test coverage, proper backward compatibility, and correct thread-safe design. Two minor observations:
-
@sinceversion tag: The@since 3.10.0tag onhasModelProblems()andsetModelProblems()inMavenSession.javais inconsistent with the existing@since 4.0.0convention used elsewhere in the file. The3.10.0was carried over from PR #298 (which targetsmaven-3.10.x), but since this is the Maven 4 codebase, using@since 4.0.0(or whatever the target Maven 4 release version is) would be more consistent. -
Duplicate simple class name: Two new classes named
SessionModelProblemsare introduced — one package-private inorg.apache.maven.api(API module) and one public inorg.apache.maven.internal.impl(core module). This would be the first instance in the codebase of the same simple name appearing in bothapiandinternal.implpackages. A distinct name for the impl class (e.g.,LegacySessionModelProblemsorSessionModelProblemsBridge) would reduce potential confusion for future maintainers.
Neither finding is blocking — the overall design is sound: thread safety via ProblemCollector's concurrent data structures, correct enum mapping, binary compatibility via default methods, proper problem propagation through multi-module collection, and thorough test coverage across unit and integration tests.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
|
The |
gnodet
left a comment
There was a problem hiding this comment.
Thanks for the quick follow-up! The rename commit cleanly resolved the duplicate class name concern — the impl class is now SessionModelProblemsBridge, and all references in MavenSession.java, DefaultSession.java, and the class file itself are updated with no stale references.
Regarding @since 3.10.0: your reasoning is sound — the tags are only on MavenSession (the 3.x legacy class), not on the Maven 4 API Session.java, so tagging with the 3.x version they first appear in is defensible.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
This ports the Maven 3 work from #298 to Maven 4 while preserving compatibility
with rules and plugins that use the legacy
MavenSessionAPI.Maven 4 now retains the model problems reported while discovering the reactor.
The native
Sessionexposes the retainedProblemCollector<ModelProblem>and ahasModelProblems()convenience method, while the legacyMavenSession#hasModelProblems()andsetModelProblems(boolean)methods bridgeto the same session state. The default native collector is backed by
SessionData, so customSessionimplementations and derived sessions share awritable collector without depending on Maven Core's
DefaultSession.Problems encountered while constructing an external parent or imported BOM are
part of the owning project's model result. Derived model-builder requests
therefore share that result's collector, preserving the collector's limits,
counts, and causes rather than copying problems afterward.
Project-collection problems are retained from the selected discovery result
before
-pland related project trimming, matching Maven 3 behavior. Problemsfrom a speculative multi-module collection attempt are buffered until that
attempt is selected; if Maven rejects it and falls back to the explicitly
requested POM, those unrelated problems are discarded. Later, unrelated
model-building operations remain outside the session collector's scope.
Binary compatibility is preserved by adding default methods to the native
SessionandProjectsSelectorinterfaces and retaining the existing projectcollection entry points. The session-data helper behind the
Sessiondefaultsis package-private.
Fixes #8485.
Verification:
mvn -pl impl/maven-impl -am -Dtest=DefaultModelBuilderTest -Dsurefire.failIfNoSpecifiedTests=false testmvn -pl impl/maven-core -am -Dtest=DefaultGraphBuilderTest,DefaultSessionTest -Dsurefire.failIfNoSpecifiedTests=false testmvn -e -B -V -Prun-its clean installMavenITRememberModelProblemsTestpassedFollowing this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.