Add phase upgrade support for Maven 4.1.0 model upgrades #11215
Merged
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.
Summary
This PR implements automatic phase name upgrades when upgrading Maven projects from model version 4.0.0 to 4.1.0. The deprecated Maven 3 phase names are automatically converted to their Maven 4 equivalents.
Changes Made
Phase Mappings
The following deprecated phase names are automatically upgraded:
pre-clean→before:cleanpost-clean→after:cleanpre-integration-test→before:integration-testpost-integration-test→after:integration-testpre-site→before:sitepost-site→after:siteImplementation Details
ModelUpgradeStrategy.java: AddedupgradePhases()method that processes all plugin executionsLifecycle.BEFORE,Lifecycle.AFTER,Lifecycle.Phase.CLEAN,Lifecycle.Phase.INTEGRATION_TEST, andLifecycle.SITEfor consistencybuild/plugins,build/pluginManagement, andprofile/build/pluginssectionsTesting
Usage
Users can now run:
And their POM files will be automatically upgraded with:
modulestosubprojectselementsExample Transformation
Before (Maven 4.0.0):
After (Maven 4.1.0):
Backward Compatibility
Testing
This enhancement provides a smooth migration path for Maven projects upgrading to version 4.1.0 by automatically handling the deprecated phase name conversions.
Pull Request opened by Augment Code with guidance from the PR author