gnodet opened a new pull request, #11215:
URL: https://github.com/apache/maven/pull/11215
## 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:clean`
- `post-clean` → `after:clean`
- `pre-integration-test` → `before:integration-test`
- `post-integration-test` → `after:integration-test`
- `pre-site` → `before:site`
- `post-site` → `after:site`
### Implementation Details
- **Enhanced `ModelUpgradeStrategy.java`**: Added `upgradePhases()` method
that processes all plugin executions
- **Uses Maven API Constants**: Leverages `Lifecycle.BEFORE`,
`Lifecycle.AFTER`, `Lifecycle.Phase.CLEAN`, `Lifecycle.Phase.INTEGRATION_TEST`,
and `Lifecycle.SITE` for consistency
- **Comprehensive Coverage**: Processes phases in `build/plugins`,
`build/pluginManagement`, and `profile/build/plugins` sections
- **Version-Specific**: Only applies when upgrading to model version 4.1.0
or higher
### Testing
- Added comprehensive unit tests covering all phase upgrade scenarios
- Tests verify upgrades work in all POM contexts (main build,
pluginManagement, profiles)
- Tests ensure non-deprecated phases are preserved unchanged
- Tests confirm phase upgrades only occur when upgrading to 4.1.0+
## Usage
Users can now run:
```bash
mvn mvnup:apply --model-version=4.1.0
```
And their POM files will be automatically upgraded with:
1. Updated model version and namespace
2. Converted `modules` to `subprojects` elements
3. **NEW**: Automatic conversion of deprecated phase names to Maven 4
equivalents
## Example Transformation
**Before (Maven 4.0.0):**
```xml
<execution>
<phase>pre-clean</phase>
<goals><goal>clean</goal></goals>
</execution>
```
**After (Maven 4.1.0):**
```xml
<execution>
<phase>before:clean</phase>
<goals><goal>clean</goal></goals>
</execution>
```
## Backward Compatibility
- Non-deprecated phase names are preserved unchanged
- Phase upgrades only apply when explicitly upgrading to model version 4.1.0+
- No impact on existing Maven 4.0.0 projects unless explicitly upgraded
## Testing
- All existing tests continue to pass
- New comprehensive test suite covers all phase upgrade scenarios
- Full Maven build succeeds
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](https://www.augmentcode.com/) with
guidance from the PR author
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]