Commit b7075bd
Fix extraneous whitespace in generated POM files
With Java 11 only (not 8, 17, or 21!), tests failed with errors like:
java.lang.AssertionError:
Unexpected: META-INF/maven/
org.scijava.scripting.java
/
Dummy
/pom.xml
Cause: the generated pom.xml has whitespace-polluted <groupId>,
<artifactId>, and <version> values.
Here's what was happening:
1. fakePOM() builds an XML document where each element's content is
stored as a CDATA section via document.createCDATASection(content).
2. The transformer is configured with OutputKeys.INDENT = "yes".
3. In Java 8 (Xalan), the transformer writes CDATA content inline:
<groupId><![CDATA[org.scijava.scripting.java]]></groupId>.
4. In Java 11, the internal XSLT transformer changed its indentation
behavior for CDATA nodes — it treats a CDATA section as a child node
distinct from inline text, and inserts a newline + indent before it
and after it:
<groupId>
<![CDATA[org.scijava.scripting.java]]>
</groupId>
5. When MiniMaven parses this POM back, getTextContent() on <groupId>
returns "\n org.scijava.scripting.java\n ", which then gets
embedded verbatim into the JAR entry path and into download URLs —
causing the MalformedURLException and the wrong JAR entry names.
The fix is in the append method: replace createCDATASection with
createTextNode. XSLT transformers universally treat text-only elements
(those with a single text-node child and no element children) as opaque
and don't inject indentation whitespace inside them.
CDATA sections and text nodes are semantically identical in XML, but
Java 11's XSLT transformer treats a CDATA node as a distinct child and
wraps it with indentation whitespace when INDENT=yes. Plain text nodes
in text-only elements are left inline.
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 9ae808e commit b7075bd
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
762 | | - | |
| 762 | + | |
763 | 763 | | |
764 | 764 | | |
765 | 765 | | |
| |||
0 commit comments