gnodet commented on issue #11760:
URL: https://github.com/apache/maven/issues/11760#issuecomment-4117681086
_Claude Code on behalf of Guillaume Nodet_
After investigating this issue, we found that it actually involves two
separate problems — one is a genuine Maven 4 regression, the other is a
pre-existing misunderstanding of how XML namespaces work with attributes.
## 1. The real Maven 4 bug: invalid consumer POM (now fixed in #11823)
The consumer POM transformation drops the `xmlns:mvn` declaration (which
lives on the `<project>` element and is lost during model serialization), but
the prefixed attributes like `mvn:combine.children` survive in plugin
configuration XML nodes. This produces invalid XML with undeclared namespace
prefixes:
```xml
<!-- consumer POM output — invalid XML -->
<compilerArgs mvn:combine.children="append"> <!-- mvn: prefix is
undeclared! -->
```
This is fixed in #11823 by properly handling namespace declarations and
prefixed attributes on the write side. When a prefixed attribute has no
corresponding `xmlns:` declaration, the prefix is stripped to produce valid XML.
## 2. `mvn:combine.children` never actually worked (not a regression)
This is the more subtle part. The `mvn:combine.children` attribute **never
triggered the append merge behavior**, even in Maven 3. We verified this by
testing with Maven 3.9.11 using a parent-child project:
**Parent POM** defines `<compilerArgs>` with `-Xlint:deprecation`.
**Child with `mvn:combine.children="append"`** (prefixed):
```xml
<compilerArgs mvn:combine.children="append">
<arg>-Xlint:unchecked</arg>
</compilerArgs>
```
Effective POM shows **only** `-Xlint:unchecked` — the parent's
`-Xlint:deprecation` is gone. The append directive was silently ignored.
**Child with `combine.children="append"`** (unprefixed):
```xml
<compilerArgs combine.children="append">
<arg>-Xlint:unchecked</arg>
</compilerArgs>
```
Effective POM shows **both** `-Xlint:deprecation` and `-Xlint:unchecked` —
append works correctly.
### Why?
Per the [XML Namespaces spec (Section
6.2)](https://www.w3.org/TR/xml-names/#defaulting), the default namespace
declaration does **not** apply to attributes. Unprefixed attributes are in **no
namespace** — not the default namespace, not any namespace. So:
- `combine.children` (unprefixed) → in **no namespace**
- `mvn:combine.children` with
`xmlns:mvn="http://maven.apache.org/POM/4.0.0"` → in the **POM namespace**
These are different attributes per the XML spec. Maven's merge logic looks
up `combine.children` (the unprefixed form), so the prefixed form is never
found.
## Recommendation for the jdbi project
The fix is simple: use unprefixed `combine.children` instead of
`mvn:combine.children`, and remove the `xmlns:mvn` declaration:
```xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="...">
...
<compilerArgs combine.children="append">
<arg>-Xlint:deprecation</arg>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
...
</project>
```
This works in both Maven 3 and Maven 4.
--
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]