-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[MNG-7830] Switch from plexus-xml to stax / woodstox #1185
Conversation
7c9420a
to
04d6bd0
Compare
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.
Wow. This looks great. definitely a big leap forward.
I might have missed it, but I didn't find any explicit use of the Stax2 API or Woodstox classes. Could this be done with JDK classes only?
classes?
maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java
Show resolved
Hide resolved
maven-model/src/test/java/org/apache/maven/model/v4/StaxTest.java
Outdated
Show resolved
Hide resolved
maven-model/src/test/java/org/apache/maven/model/v4/StaxTest.java
Outdated
Show resolved
Hide resolved
maven-model/src/test/java/org/apache/maven/model/v4/StaxTest.java
Outdated
Show resolved
Hide resolved
maven-model/src/test/java/org/apache/maven/model/v4/StaxTest.java
Outdated
Show resolved
Hide resolved
@@ -32,6 32,14 @@ under the License. | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-xml</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.woodstox</groupId> | |||
<artifactId>stax2-api</artifactId> |
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.
Do we need stax2 or could we get away with the stax version in the JDK?
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.
Yes, the round tripping (i.e. read the xml using stax and write it back to a string without any difference) is only supported by woodstox (the stax2-api
is a mandatory dependency of woodstox anyway).
maven-model-transform/src/main/java/org/apache/maven/model/transform/stax/XmlUtils.java
Show resolved
Hide resolved
maven-model-transform/src/main/java/org/apache/maven/model/transform/stax/XmlUtils.java
Outdated
Show resolved
Hide resolved
Stax2 / woodstox is actually needed for the consumer POM transformation: the stax api is not sufficient and does not allow full round tripping with xml as spaces in prolog are not reported. Even aalto-xml does not support it. The effect is that when using another implementation, the line breaks before the first element of the POM are removed, so the generated POM will usually contains the xml declaration, the license and the Apart from this use case, changing the implementation leads to various small issues as they do sometimes slightly differ in the specific events they generate. Writing namespaces is particularly challenging, though there's certainly a way to solve those discrepancies, but again, it breaks a few ITs which are particularly sensitive to the exact XML generated. Also, woodstox is 50% faster than the JDK implementation, so I definitely think we should use it. |
Depending on spaces in the prolog is a bug. Tests should be comparing XML to XML, not XML to strings. The latter is extremely brittle and can cause tests to break even in minor upgrades of a library. Alternately, we can canonicalize documents before comparing them. If you file issues on specific tests that do that, I can take a look. |
That's not really the problem. I could hack the tests. However, the result xml is the one uploaded on central, and that one is ugly (because of the missing line breaks). So I think this is important to keep. |
d232c27
to
543ea16
Compare
I am sure there are ways to fix that. |
Might or might not be related: [INFO] Error: ProjectBuilderTest.testReadModifiedPoms(Path) � IO Failed to delete temp directory C:\Users\RUNNER~1\AppData\Local\Temp\junit3720686351607426598. The following paths could not be deleted (see suppressed exceptions for details): , child |
I plan to provide additional support for xml namespaces, but I think a follow-up PR may be better. I'll stop on that one. |
JIRA issue: https://issues.apache.org/jira/browse/MNG-7830
IT PR: apache/maven-integration-testing#274
Switch the underlying plexus-xml Xpp3 parser to the STAX api / woodstox parser.
Woodstox Stax parser is 20% faster than the xpp3 parser.
The PR also moves out of modello generated code for the repository metadata and core extensions xml models.
Some pom are not valid xml files, for example:
The
StaxTest
unit test (disabled by default) reads all POMs in the local repository.We could disable namespace support when reading the POMs, but I'm not sure that's a good idea.