Skip to content
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

Remove references to Xpp3DomBuilder and use XmlNodeBuilder instead #1045

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down