-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix mvnup tool issues #7934-#7938 #9311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
This commit addresses five critical issues with the Maven upgrade tool (mvnup): **Issue apache#7934: External parent preservation** - Fixed InferenceStrategy to detect external parents vs reactor parents - External parents now preserve required groupId, artifactId, and version elements - Prevents 'parent.groupId is missing' errors when using META-POMs **Issue apache#7935: .mvn directory creation for all model versions** - Modified AbstractUpgradeGoal to create .mvn directory for both 4.0.0 and 4.1.0 - Helps Maven find project root and avoids root directory warnings **Issue apache#7936: Downgrade error handling** - Changed ModelUpgradeStrategy to fail with errors instead of warnings for invalid downgrades - Tool now properly exits with error code when attempting 4.1.0 → 4.0.0 downgrade **Issue apache#7937: Unicode icon fallback** - Enhanced UpgradeContext to detect Unicode support using terminal.stdoutEncoding() - Falls back to ASCII characters ([OK], [ERROR], etc.) when Unicode not supported - Improves compatibility with Windows CMD/PowerShell and other terminals **Issue apache#7938: Child version removal in 4.1.0** - Enhanced inference logic to properly remove matching child versions in subprojects - Ensures child project versions are removed when they match parent version **Testing:** - Updated existing tests to reflect correct behavior - Added new tests for downgrade handling and Unicode detection - All mvnup tests passing with comprehensive coverage Fixes apache#7934, apache#7935, apache#7936, apache#7937, apache#7938
- Replace heuristic-based approach with direct GAV matching against pomMap - More accurate detection of external vs reactor parents - Added comprehensive test coverage for both scenarios - Suggested by code review feedback
- Replace manual GAV extraction with existing GAVUtils method - More robust handling of parent resolution and inheritance - Leverages existing tested utility for GAV extraction - Cleaner and more maintainable code
elharo
reviewed
Jul 9, 2025
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeContext.java
Outdated
Show resolved
Hide resolved
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeContext.java
Outdated
Show resolved
Hide resolved
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeContext.java
Outdated
Show resolved
Hide resolved
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeContext.java
Outdated
Show resolved
Hide resolved
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeContext.java
Outdated
Show resolved
Hide resolved
Bukama
requested changes
Jul 10, 2025
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeContext.java
Outdated
Show resolved
Hide resolved
…ction This commit addresses all review feedback from @elharo and @Bukama: **Icon Management Improvements:** - Created ConsoleIcon enum with Unicode/ASCII fallback pairs - Moved all icon logic into the enum for consistency and reusability - Implemented ConsoleIcon.getIcon(Terminal) for clean integration **Unicode Detection Enhancements:** - Use Charset.newEncoder().canEncode(char) for accurate character testing - Use terminal.encoding() instead of deprecated stdoutEncoding() - Simplified fallback to Charset.defaultCharset() - Removed complex heuristics and exception handling **Code Quality Improvements:** - UpgradeContext methods are now clean one-liners - Better separation of concerns between icon rendering and context management - Comprehensive test coverage for all scenarios - Future-proof design for adding new icons **Review Comments Addressed:** - @elharo: 'maybe this should be a field that can be shared?' → Icons now shared via enum - @Bukama: 'maybe an enum with icon and fallback text?' → Implemented with Terminal integration - @elharo: 'There are others that also support Unicode, e.g. UCS-2., UCS-4' → Now tests actual encoding capability - @elharo: 'Please be specific about exceptions' → No longer needed with simplified approach - @elharo: 'toLowerCase(Locale.ENGLISH)' → No longer needed with canEncode() approach **Technical Benefits:** - More accurate Unicode detection per character - Works with any charset automatically - Cleaner and more maintainable code - Better test coverage and reliability
Bukama
approved these changes
Jul 10, 2025
Contributor
Bukama
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for update :)
rmannibucau
approved these changes
Jul 15, 2025
Contributor
Author
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
gnodet
added a commit
to gnodet/maven
that referenced
this pull request
Jul 15, 2025
* Fix mvnup tool issues apache#7934-apache#7938 This commit addresses five critical issues with the Maven upgrade tool (mvnup): **Issue apache#7934: External parent preservation** - Fixed InferenceStrategy to detect external parents vs reactor parents - External parents now preserve required groupId, artifactId, and version elements - Prevents 'parent.groupId is missing' errors when using META-POMs **Issue apache#7935: .mvn directory creation for all model versions** - Modified AbstractUpgradeGoal to create .mvn directory for both 4.0.0 and 4.1.0 - Helps Maven find project root and avoids root directory warnings **Issue apache#7936: Downgrade error handling** - Changed ModelUpgradeStrategy to fail with errors instead of warnings for invalid downgrades - Tool now properly exits with error code when attempting 4.1.0 → 4.0.0 downgrade **Issue apache#7937: Unicode icon fallback** - Enhanced UpgradeContext to detect Unicode support using terminal.stdoutEncoding() - Falls back to ASCII characters ([OK], [ERROR], etc.) when Unicode not supported - Improves compatibility with Windows CMD/PowerShell and other terminals **Issue apache#7938: Child version removal in 4.1.0** - Enhanced inference logic to properly remove matching child versions in subprojects - Ensures child project versions are removed when they match parent version **Testing:** - Updated existing tests to reflect correct behavior - Added new tests for downgrade handling and Unicode detection - All mvnup tests passing with comprehensive coverage Fixes apache#7934, apache#7935, apache#7936, apache#7937, apache#7938 * Improve parent reactor detection logic - Replace heuristic-based approach with direct GAV matching against pomMap - More accurate detection of external vs reactor parents - Added comprehensive test coverage for both scenarios - Suggested by code review feedback * Refactor to use GAVUtils.extractGAVWithParentResolution - Replace manual GAV extraction with existing GAVUtils method - More robust handling of parent resolution and inheritance - Leverages existing tested utility for GAV extraction - Cleaner and more maintainable code * Address review feedback: Implement ConsoleIcon enum with charset detection This commit addresses all review feedback from @elharo and @Bukama: **Icon Management Improvements:** - Created ConsoleIcon enum with Unicode/ASCII fallback pairs - Moved all icon logic into the enum for consistency and reusability - Implemented ConsoleIcon.getIcon(Terminal) for clean integration **Unicode Detection Enhancements:** - Use Charset.newEncoder().canEncode(char) for accurate character testing - Use terminal.encoding() instead of deprecated stdoutEncoding() - Simplified fallback to Charset.defaultCharset() - Removed complex heuristics and exception handling **Code Quality Improvements:** - UpgradeContext methods are now clean one-liners - Better separation of concerns between icon rendering and context management - Comprehensive test coverage for all scenarios - Future-proof design for adding new icons **Review Comments Addressed:** - @elharo: 'maybe this should be a field that can be shared?' → Icons now shared via enum - @Bukama: 'maybe an enum with icon and fallback text?' → Implemented with Terminal integration - @elharo: 'There are others that also support Unicode, e.g. UCS-2., UCS-4' → Now tests actual encoding capability - @elharo: 'Please be specific about exceptions' → No longer needed with simplified approach - @elharo: 'toLowerCase(Locale.ENGLISH)' → No longer needed with canEncode() approach **Technical Benefits:** - More accurate Unicode detection per character - Works with any charset automatically - Cleaner and more maintainable code - Better test coverage and reliability (cherry picked from commit adf2c49)
gnodet
added a commit
that referenced
this pull request
Jul 16, 2025
* Fix mvnup tool issues #7934-#7938 This commit addresses five critical issues with the Maven upgrade tool (mvnup): **Issue #7934: External parent preservation** - Fixed InferenceStrategy to detect external parents vs reactor parents - External parents now preserve required groupId, artifactId, and version elements - Prevents 'parent.groupId is missing' errors when using META-POMs **Issue #7935: .mvn directory creation for all model versions** - Modified AbstractUpgradeGoal to create .mvn directory for both 4.0.0 and 4.1.0 - Helps Maven find project root and avoids root directory warnings **Issue #7936: Downgrade error handling** - Changed ModelUpgradeStrategy to fail with errors instead of warnings for invalid downgrades - Tool now properly exits with error code when attempting 4.1.0 → 4.0.0 downgrade **Issue #7937: Unicode icon fallback** - Enhanced UpgradeContext to detect Unicode support using terminal.stdoutEncoding() - Falls back to ASCII characters ([OK], [ERROR], etc.) when Unicode not supported - Improves compatibility with Windows CMD/PowerShell and other terminals **Issue #7938: Child version removal in 4.1.0** - Enhanced inference logic to properly remove matching child versions in subprojects - Ensures child project versions are removed when they match parent version **Testing:** - Updated existing tests to reflect correct behavior - Added new tests for downgrade handling and Unicode detection - All mvnup tests passing with comprehensive coverage Fixes #7934, #7935, #7936, #7937, #7938 * Improve parent reactor detection logic - Replace heuristic-based approach with direct GAV matching against pomMap - More accurate detection of external vs reactor parents - Added comprehensive test coverage for both scenarios - Suggested by code review feedback * Refactor to use GAVUtils.extractGAVWithParentResolution - Replace manual GAV extraction with existing GAVUtils method - More robust handling of parent resolution and inheritance - Leverages existing tested utility for GAV extraction - Cleaner and more maintainable code * Address review feedback: Implement ConsoleIcon enum with charset detection This commit addresses all review feedback from @elharo and @Bukama: **Icon Management Improvements:** - Created ConsoleIcon enum with Unicode/ASCII fallback pairs - Moved all icon logic into the enum for consistency and reusability - Implemented ConsoleIcon.getIcon(Terminal) for clean integration **Unicode Detection Enhancements:** - Use Charset.newEncoder().canEncode(char) for accurate character testing - Use terminal.encoding() instead of deprecated stdoutEncoding() - Simplified fallback to Charset.defaultCharset() - Removed complex heuristics and exception handling **Code Quality Improvements:** - UpgradeContext methods are now clean one-liners - Better separation of concerns between icon rendering and context management - Comprehensive test coverage for all scenarios - Future-proof design for adding new icons **Review Comments Addressed:** - @elharo: 'maybe this should be a field that can be shared?' → Icons now shared via enum - @Bukama: 'maybe an enum with icon and fallback text?' → Implemented with Terminal integration - @elharo: 'There are others that also support Unicode, e.g. UCS-2., UCS-4' → Now tests actual encoding capability - @elharo: 'Please be specific about exceptions' → No longer needed with simplified approach - @elharo: 'toLowerCase(Locale.ENGLISH)' → No longer needed with canEncode() approach **Technical Benefits:** - More accurate Unicode detection per character - Works with any charset automatically - Cleaner and more maintainable code - Better test coverage and reliability (cherry picked from commit adf2c49)
This was referenced Jul 18, 2025
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.
Summary
This PR addresses five critical issues with the Maven upgrade tool (mvnup) reported in issues #7934, #7935, #7936, #7937, and #7938.
Issues Fixed
🔧 Issue #7934: External parent preservation
groupIdandartifactIdfrom external META-POMs, causing "parent.groupId is missing" errorsInferenceStrategyto detect external parents vs reactor parents and preserve required elements for external parents🔧 Issue #7935: .mvn directory creation for all model versions
.mvndirectory was only created for 4.0.0 upgrades, not 4.1.0, causing root directory warningsAbstractUpgradeGoalto create.mvndirectory for both 4.0.0 and 4.1.0 upgrades🔧 Issue #7936: Downgrade error handling
ModelUpgradeStrategyto fail with errors instead of warnings for invalid version transitions🔧 Issue #7937: Unicode icon fallback
UpgradeContextto detect Unicode support usingterminal.stdoutEncoding()and fall back to ASCII characters🔧 Issue #7938: Child version removal in 4.1.0
Technical Details
Key Changes
InferenceStrategy.java:
isParentInReactor()method to distinguish external vs reactor parentstrimParentElementFull()to preserve external parent elementsAbstractUpgradeGoal.java:
.mvndirectory creation based on model version.mvndirectory for all upgrade scenariosModelUpgradeStrategy.java:
UpgradeContext.java:
terminal.stdoutEncoding()check[OK],[ERROR],[WARNING],-,>Testing
ModelUpgradeStrategyTest)UpgradeContextTest)Backward Compatibility
Testing Performed
Manual Testing:
.mvndirectory creation for both 4.0.0 and 4.1.0Automated Testing:
Files Changed
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeContext.javaimpl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/AbstractUpgradeGoal.javaimpl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/InferenceStrategy.javaimpl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/ModelUpgradeStrategy.javaUpgradeContextTest.javaChecklist
Closes #7934, #7935, #7936, #7937, #7938
Pull Request opened by Augment Code with guidance from the PR author