Skip to content

Commit

Permalink
[MNG-7655] Switch to plexus-utils / plexus-xml 4 (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jun 4, 2023
1 parent c124554 commit e08c95a
Show file tree
Hide file tree
Showing 29 changed files with 72 additions and 817 deletions.
1 change: 0 additions & 1 deletion apache-maven/src/assembly/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ under the License.
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>org.codehaus.plexus:plexus-classworlds</exclude>
<exclude>org.codehaus.plexus:plexus-utils</exclude>
</excludes>
</dependencySet>
</dependencySets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
*/
package org.apache.maven.usability.plugin;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
Expand All @@ -31,7 +29,6 @@
import java.util.Map;

import org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

/**
Expand Down Expand Up @@ -100,11 +97,9 @@ public static Map<String, Expression> load() throws ExpressionDocumentationExcep
*/
private static Map<String, Expression> parseExpressionDocumentation(InputStream docStream)
throws IOException, XmlPullParserException {
Reader reader = new BufferedReader(ReaderFactory.newXmlReader(docStream));

ParamdocXpp3Reader paramdocReader = new ParamdocXpp3Reader();

ExpressionDocumentation documentation = paramdocReader.read(reader, true);
ExpressionDocumentation documentation = paramdocReader.read(docStream, true);

List<Expression> expressions = documentation.getExpressions();

Expand Down
2 changes: 1 addition & 1 deletion maven-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ under the License.
</dependency>
<!-- Plexus -->
<dependency>
<groupId>org.apache.maven</groupId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.apache.maven.api.services.xml.XmlWriterRequest;
import org.apache.maven.model.v4.MavenXpp3ReaderEx;
import org.apache.maven.model.v4.MavenXpp3WriterEx;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.XmlStreamReader;

import static org.apache.maven.internal.impl.Utils.nonNull;

Expand All @@ -64,11 +64,11 @@ public Model read(@Nonnull XmlReaderRequest request) throws XmlReaderException {
MavenXpp3ReaderEx xml = new MavenXpp3ReaderEx();
xml.setAddDefaultEntities(request.isAddDefaultEntities());
if (path != null) {
reader = ReaderFactory.newXmlReader(path.toFile());
reader = new XmlStreamReader(path.toFile());
} else if (url != null) {
reader = ReaderFactory.newXmlReader(url);
reader = new XmlStreamReader(url);
} else if (inputStream != null) {
reader = ReaderFactory.newXmlReader(inputStream);
reader = new XmlStreamReader(inputStream);
}
return xml.read(reader, request.isStrict(), source);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -101,7 +100,6 @@
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.graph.DependencyFilter;
Expand Down Expand Up @@ -264,10 +262,8 @@ private String getPluginDescriptorLocation() {
private PluginDescriptor parsePluginDescriptor(InputStream is, Plugin plugin, String descriptorLocation)
throws PluginDescriptorParsingException {
try {
Reader reader = ReaderFactory.newXmlReader(is);

return builder.build(reader, descriptorLocation);
} catch (IOException | PlexusConfigurationException e) {
return builder.build(is, descriptorLocation);
} catch (PlexusConfigurationException e) {
throw new PluginDescriptorParsingException(plugin, descriptorLocation, e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion maven-model-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ under the License.
<version>4.0.0-alpha-6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions maven-model-transform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ under the License.

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
4 changes: 4 additions & 0 deletions maven-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ under the License.
<artifactId>maven-xml-impl</artifactId>
<version>4.0.0-alpha-6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
import org.codehaus.plexus.util.xml.pull.MXParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
Expand Down Expand Up @@ -53,8 +52,6 @@ public boolean getAddDefaultEntities() {
} // -- boolean getAddDefaultEntities()

/**
* @see ReaderFactory#newXmlReader
*
* @param reader a reader object.
* @param strict a strict object.
* @throws IOException IOException if any.
Expand All @@ -70,8 +67,6 @@ public Model read(Reader reader, boolean strict, InputSource source) throws IOEx
} // -- Model read( Reader, boolean )

/**
* @see ReaderFactory#newXmlReader
*
* @param reader a reader object.
* @throws IOException IOException if any.
* @throws XmlPullParserException XmlPullParserException if
Expand All @@ -93,7 +88,10 @@ public Model read(Reader reader, InputSource source) throws IOException, XmlPull
* @return Model
*/
public Model read(InputStream in, boolean strict, InputSource source) throws IOException, XmlPullParserException {
return read(ReaderFactory.newXmlReader(in), strict, source);
XmlPullParser parser =
addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser();
parser.setInput(in, null);
return read(parser, strict, source);
} // -- Model read( InputStream, boolean )

/**
Expand All @@ -106,7 +104,7 @@ public Model read(InputStream in, boolean strict, InputSource source) throws IOE
* @return Model
*/
public Model read(InputStream in, InputSource source) throws IOException, XmlPullParserException {
return read(ReaderFactory.newXmlReader(in), source);
return read(in, true, source);
} // -- Model read( InputStream )

/**
Expand Down
2 changes: 1 addition & 1 deletion maven-plugin-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ under the License.
<artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.plugin.descriptor;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -44,6 +45,10 @@ public PluginDescriptor build(Reader reader, String source) throws PlexusConfigu
return build(source, buildConfiguration(reader));
}

public PluginDescriptor build(InputStream input, String source) throws PlexusConfigurationException {
return build(source, buildConfiguration(input));
}

private PluginDescriptor build(String source, PlexusConfiguration c) throws PlexusConfigurationException {
PluginDescriptor pluginDescriptor = new PluginDescriptor();

Expand Down Expand Up @@ -374,4 +379,12 @@ public PlexusConfiguration buildConfiguration(Reader configuration) throws Plexu
throw new PlexusConfigurationException(e.getMessage(), e);
}
}

public PlexusConfiguration buildConfiguration(InputStream configuration) throws PlexusConfigurationException {
try {
return XmlPlexusConfiguration.toPlexusConfiguration(XmlNodeBuilder.build(configuration, null));
} catch (IOException | XmlPullParserException e) {
throw new PlexusConfigurationException(e.getMessage(), e);
}
}
}
4 changes: 2 additions & 2 deletions maven-repository-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ under the License.

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
Expand Down
2 changes: 1 addition & 1 deletion maven-resolver-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ under the License.
<artifactId>maven-resolver-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion maven-settings-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ under the License.
<artifactId>plexus-interpolation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.file.Files;
import java.util.Map;
import java.util.Objects;

import org.apache.maven.settings.Settings;
import org.apache.maven.settings.v4.SettingsXpp3Reader;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

/**
Expand All @@ -46,7 +46,11 @@ public class DefaultSettingsReader implements SettingsReader {
public Settings read(File input, Map<String, ?> options) throws IOException {
Objects.requireNonNull(input, "input cannot be null");

return read(ReaderFactory.newXmlReader(input), options);
try (InputStream in = Files.newInputStream(input.toPath())) {
return new Settings(new SettingsXpp3Reader().read(in, isStrict(options)));
} catch (XmlPullParserException e) {
throw new SettingsParseException(e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import org.apache.maven.settings.Settings;
import org.apache.maven.settings.v4.SettingsXpp3Writer;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.xml.XmlStreamWriter;

/**
* Handles serialization of settings into the default textual format.
Expand All @@ -49,7 +49,7 @@ public void write(File output, Map<String, Object> options, Settings settings) t

output.getParentFile().mkdirs();

write(WriterFactory.newXmlWriter(output), options, settings);
write(new XmlStreamWriter(output), options, settings);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions maven-settings/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ under the License.
<version>4.0.0-alpha-6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>plexus-utils</artifactId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.Reader;

import org.apache.maven.settings.Settings;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
import org.codehaus.plexus.util.xml.pull.MXParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
Expand Down Expand Up @@ -52,8 +51,6 @@ public boolean getAddDefaultEntities() {
} // -- boolean getAddDefaultEntities()

/**
* @see ReaderFactory#newXmlReader
*
* @param reader a reader object.
* @param strict a strict object.
* @throws IOException IOException if any.
Expand All @@ -69,8 +66,6 @@ public Settings read(Reader reader, boolean strict) throws IOException, XmlPullP
} // -- Model read( Reader, boolean )

/**
* @see ReaderFactory#newXmlReader
*
* @param reader a reader object.
* @throws IOException IOException if any.
* @throws XmlPullParserException XmlPullParserException if
Expand All @@ -92,7 +87,10 @@ public Settings read(Reader reader) throws IOException, XmlPullParserException {
* @return Settings
*/
public Settings read(InputStream in, boolean strict) throws IOException, XmlPullParserException {
return read(ReaderFactory.newXmlReader(in), strict);
XmlPullParser parser =
addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser();
parser.setInput(in, null);
return read(parser, strict);
} // -- Model read( InputStream, boolean )

/**
Expand All @@ -105,7 +103,7 @@ public Settings read(InputStream in, boolean strict) throws IOException, XmlPull
* @return Settings
*/
public Settings read(InputStream in) throws IOException, XmlPullParserException {
return read(ReaderFactory.newXmlReader(in));
return read(in, true);
} // -- Model read( InputStream )

/**
Expand Down
2 changes: 1 addition & 1 deletion maven-toolchain-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ under the License.
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.file.Files;
import java.util.Map;
import java.util.Objects;

import org.apache.maven.toolchain.model.PersistedToolchains;
import org.apache.maven.toolchain.v4.MavenToolchainsXpp3Reader;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

/**
Expand All @@ -47,7 +47,11 @@ public class DefaultToolchainsReader implements ToolchainsReader {
public PersistedToolchains read(File input, Map<String, ?> options) throws IOException {
Objects.requireNonNull(input, "input cannot be null");

return read(ReaderFactory.newXmlReader(input), options);
try (InputStream in = Files.newInputStream(input.toPath())) {
return new PersistedToolchains(new MavenToolchainsXpp3Reader().read(in, isStrict(options)));
} catch (XmlPullParserException e) {
throw new ToolchainsParseException(e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e);
}
}

@Override
Expand Down
Loading

0 comments on commit e08c95a

Please sign in to comment.