Remove references to Xpp3DomBuilder and use XmlNodeBuilder instead (#1045)

This commit is contained in:
Guillaume Nodet 2023-03-09 16:26:58 +01:00 committed by GitHub
parent 1922e01831
commit 10128b4484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 23 deletions

View File

@ -25,8 +25,8 @@
import java.nio.file.Paths;
import org.apache.maven.configuration.internal.DefaultBeanConfigurator;
import org.apache.maven.internal.xml.XmlNodeBuilder;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -53,7 +53,7 @@ public void tearDown() throws Exception {
private Xpp3Dom toConfig(String xml) {
try {
return Xpp3DomBuilder.build(new StringReader("<configuration>" + xml + "</configuration>"));
return new Xpp3Dom(XmlNodeBuilder.build(new StringReader("<configuration>" + xml + "</configuration>")));
} catch (XmlPullParserException | IOException e) {
throw new IllegalArgumentException(e);
}

View File

@ -23,8 +23,8 @@
import java.io.StringReader;
import org.apache.maven.configuration.internal.DefaultBeanConfigurator;
import org.apache.maven.internal.xml.XmlNodeBuilder;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -51,7 +51,7 @@ public void tearDown() throws Exception {
private Xpp3Dom toConfig(String xml) {
try {
return Xpp3DomBuilder.build(new StringReader("<configuration>" + xml + "</configuration>"));
return new Xpp3Dom(XmlNodeBuilder.build(new StringReader("<configuration>" + xml + "</configuration>")));
} catch (XmlPullParserException | IOException e) {
throw new IllegalArgumentException(e);
}

View File

@ -40,7 +40,6 @@
import org.apache.maven.api.xml.XmlNode;
import org.apache.maven.internal.xml.XmlNodeBuilder;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.MXParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@ -116,7 +115,7 @@ private Object parse(final MXParser parser, final TypeLiteral<?> toType) throws
return XmlNodeBuilder.build(parser);
}
if (Xpp3Dom.class.isAssignableFrom(rawType)) {
return parseXpp3Dom(parser);
return new Xpp3Dom(XmlNodeBuilder.build(parser));
}
if (Properties.class.isAssignableFrom(rawType)) {
return parseProperties(parser);
@ -133,16 +132,6 @@ private Object parse(final MXParser parser, final TypeLiteral<?> toType) throws
return parseBean(parser, toType, rawType);
}
/**
* Parses an XML subtree and converts it to the {@link Xpp3Dom} type.
*
* @param parser The XML parser
* @return Converted Xpp3Dom instance
*/
private static Xpp3Dom parseXpp3Dom(final XmlPullParser parser) throws Exception {
return Xpp3DomBuilder.build(parser);
}
/**
* Parses a sequence of XML elements and converts them to the appropriate {@link Properties} type.
*

View File

@ -18,7 +18,7 @@
*/
package org.apache.maven.repository.internal;
import java.io.Reader;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
@ -30,10 +30,9 @@
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import org.apache.maven.api.xml.XmlNode;
import org.apache.maven.internal.xml.XmlNodeBuilder;
import org.apache.maven.repository.internal.PluginsMetadata.PluginInfo;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.deployment.DeployRequest;
@ -123,14 +122,13 @@ private PluginInfo extractPluginInfo(Artifact artifact) {
ZipEntry pluginDescriptorEntry = artifactJar.getEntry(PLUGIN_DESCRIPTOR_LOCATION);
if (pluginDescriptorEntry != null) {
try (Reader reader =
ReaderFactory.newXmlReader(artifactJar.getInputStream(pluginDescriptorEntry))) {
try (InputStream is = artifactJar.getInputStream(pluginDescriptorEntry)) {
// Note: using DOM instead of use of
// org.apache.maven.plugin.descriptor.PluginDescriptor
// as it would pull in dependency on:
// - maven-plugin-api (for model)
// - Plexus Container (for model supporting classes and exceptions)
Xpp3Dom root = Xpp3DomBuilder.build(reader);
XmlNode root = XmlNodeBuilder.build(is, null);
String groupId = root.getChild("groupId").getValue();
String artifactId = root.getChild("artifactId").getValue();
String goalPrefix = root.getChild("goalPrefix").getValue();