gnodet commented on code in PR #12160:
URL: https://github.com/apache/maven/pull/12160#discussion_r3354385465
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/CompatibilityFixStrategy.java:
##########
@@ -164,44 +168,44 @@ public UpgradeResult doApply(UpgradeContext context,
Map<Path, Document> pomMap)
/**
* Fixes unsupported combine.children attribute values.
- * Maven 4 only supports 'append' and 'merge', not 'override'.
+ * Maven 4 only supports 'append' and 'merge' (default is merge).
+ * Invalid values are removed entirely since Maven 3 silently ignored them.
*/
private boolean fixUnsupportedCombineChildrenAttributes(Document
pomDocument, UpgradeContext context) {
- boolean fixed = false;
Element root = pomDocument.root();
- // Find all elements with combine.children="override" and change to
"merge"
- long fixedCombineChildrenCount = findElementsWithAttribute(root,
COMBINE_CHILDREN, COMBINE_OVERRIDE)
- .peek(element -> {
-
element.attributeObject(COMBINE_CHILDREN).value(COMBINE_MERGE);
- context.detail("Fixed: " + COMBINE_CHILDREN + "='" +
COMBINE_OVERRIDE + "' → '" + COMBINE_MERGE
- + "' in " + element.name());
- })
- .count();
- fixed |= fixedCombineChildrenCount > 0;
+ List<Element> invalidElements = findElementsWithInvalidAttribute(
+ root, COMBINE_CHILDREN, VALID_COMBINE_CHILDREN_VALUES)
+ .toList();
- return fixed;
+ for (Element element : invalidElements) {
Review Comment:
Maven 4 already validates these at runtime:
`DefaultModelValidator.validateXmlNode()` (lines 815-852) raises a
`Severity.ERROR` for any unsupported `combine.self` or `combine.children`
value. So invalid POMs will fail the build.
The whole point of mvnup is to fix these proactively — if someone has
`combine.self="append"` (which Maven 3 silently ignored), mvnup removes it
*before* Maven 4 rejects it. Running mvnup on an invalid POM and having it fix
the problem is exactly the expected workflow. Failing and telling the user
"your POM is invalid, go fix it yourself" would defeat the purpose.
--
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]