[Backport 4.0.x] Fix ToolchainPluginStrategy to detect inherited source levels from parent POMs - #13025
Merged
Conversation
…rent POMs * Fix ToolchainPluginStrategy to detect inherited source levels from parent POMs When a project inherits --source/--release from a remote parent POM (e.g. org.apache.sling:sling-parent setting --source 6), mvnup's ToolchainPluginStrategy failed to detect it because detectSourceLevel() only inspected the local POM XML DOM. This caused mvnup to skip adding the toolchains plugin, leading to Maven 4 build failures. Changes: - Share the Maven 4 API Session across all strategy instances (DCL singleton) so the Session's RequestCache deduplicates effective model builds across PluginUpgradeStrategy, ToolchainPluginStrategy, and CompatibilityFixStrategy - Route buildEffectiveModel() through InternalSession.request() to leverage the RequestCache - Add effective model fallback in ToolchainPluginStrategy: when local POM has no source level, resolve the effective model to pick up inherited compiler configuration from parent POMs - Add 8 new tests for effective model source level detection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Extract MvnupSessionHolder with @provides @singleton Session producer Move the Maven 4 API Session creation from AbstractUpgradeStrategy into a dedicated MvnupSessionHolder class that uses @provides @singleton to produce the Session as a DI-managed bean. The DI container calls createSession() once and injects the singleton Session into all strategy instances via @Inject @nAmed("mvnup") field injection on the abstract base class. This replaces the manual DCL singleton pattern with proper DI lifecycle management. A static fallback in getSession() preserves backward compatibility for unit tests that instantiate strategies directly (without DI). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Address review: add groupId check in effective model plugin detection and fix Javadoc accuracy Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
@gnodet Please assign appropriate label to PR according to the type of change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #12973 to maven-4.0.x.
Cherry-pick of 2144fbd.