diff --git a/maven-plugin-testing-harness/pom.xml b/maven-plugin-testing-harness/pom.xml index aaec2bb..d5ebe25 100644 --- a/maven-plugin-testing-harness/pom.xml +++ b/maven-plugin-testing-harness/pom.xml @@ -39,7 +39,7 @@ under the License. org.junit junit-bom - 5.10.2 + 5.11.0 pom import @@ -116,7 +116,6 @@ under the License. org.codehaus.plexus plexus-utils - 3.5.1 org.codehaus.plexus diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java index c2b2309..8c11a8f 100644 --- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java +++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java @@ -72,7 +72,6 @@ import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.util.InterpolationFilterReader; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.ReflectionUtils; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.XmlStreamReader; @@ -297,7 +296,7 @@ protected T lookupEmptyMojo(String goal, String pluginPom) thro protected T lookupMojo(String goal, File pom) throws Exception { File pluginPom = new File(getBasedir(), "pom.xml"); - Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(pluginPom)); + Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(new XmlStreamReader(pluginPom)); String artifactId = pluginPomDom.getChild("artifactId").getValue(); @@ -321,7 +320,7 @@ protected T lookupMojo(String goal, File pom) throws Exception protected T lookupEmptyMojo(String goal, File pom) throws Exception { File pluginPom = new File(getBasedir(), "pom.xml"); - Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(pluginPom)); + Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(new XmlStreamReader(pluginPom)); String artifactId = pluginPomDom.getChild("artifactId").getValue(); @@ -507,7 +506,7 @@ private void finalizeMojoConfiguration(MojoExecution mojoExecution) { */ protected PlexusConfiguration extractPluginConfiguration(String artifactId, File pom) throws Exception { - try (Reader reader = ReaderFactory.newXmlReader(pom)) { + try (Reader reader = new XmlStreamReader(pom)) { Xpp3Dom pomDom = Xpp3DomBuilder.build(reader); return extractPluginConfiguration(artifactId, pomDom); } diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/junit5/MojoExtension.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/junit5/MojoExtension.java index 247b7f9..3290ab3 100644 --- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/junit5/MojoExtension.java +++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/junit5/MojoExtension.java @@ -69,7 +69,6 @@ import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.testing.PlexusExtension; import org.codehaus.plexus.util.InterpolationFilterReader; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.ReflectionUtils; import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -203,18 +202,18 @@ private Mojo lookupMojo( Xpp3Dom pomDom; if (pom.startsWith("file:")) { Path path = Paths.get(getBasedir()).resolve(pom.substring("file:".length())); - pomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(path.toFile())); + pomDom = Xpp3DomBuilder.build(new XmlStreamReader(path.toFile())); } else if (pom.startsWith("classpath:")) { URL url = holder.getResource(pom.substring("classpath:".length())); if (url == null) { throw new IllegalStateException("Unable to find pom on classpath: " + pom); } - pomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(url.openStream())); + pomDom = Xpp3DomBuilder.build(new XmlStreamReader(url.openStream())); } else if (pom.contains("")) { pomDom = Xpp3DomBuilder.build(new StringReader(pom)); } else { Path path = Paths.get(getBasedir()).resolve(pom); - pomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(path.toFile())); + pomDom = Xpp3DomBuilder.build(new XmlStreamReader(path.toFile())); } Xpp3Dom pluginConfiguration = extractPluginConfiguration(coord[1], pomDom); if (!mojoParameters.isEmpty()) { @@ -238,7 +237,7 @@ protected String[] mojoCoordinates(String goal) throws Exception { return goal.split(":"); } else { Path pluginPom = Paths.get(getBasedir(), "pom.xml"); - Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(pluginPom.toFile())); + Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(new XmlStreamReader(pluginPom.toFile())); String artifactId = pluginPomDom.getChild("artifactId").getValue(); String groupId = resolveFromRootThenParent(pluginPomDom, "groupId"); String version = resolveFromRootThenParent(pluginPomDom, "version"); @@ -263,11 +262,10 @@ protected Mojo lookupMojo(String[] coord, Xpp3Dom pluginConfiguration, PluginDes } if (pluginConfiguration != null) { MavenSession session = getContainer().lookup(MavenSession.class); - MavenProject project; try { - project = getContainer().lookup(MavenProject.class); - } catch (ComponentLookupException e) { - project = null; + getContainer().lookup(MavenProject.class); + } catch (ComponentLookupException ignore) { + // nothing } MojoExecution mojoExecution; try { diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/MavenProjectStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/MavenProjectStub.java index 513629b..ab2e517 100644 --- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/MavenProjectStub.java +++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/MavenProjectStub.java @@ -58,7 +58,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; @@ -186,7 +186,7 @@ protected void readModel(File pomFile) { pomFile = new File(getBasedir(), pomFile.getPath()); } try { - setModel(new MavenXpp3Reader().read(ReaderFactory.newXmlReader(pomFile))); + setModel(new MavenXpp3Reader().read(new XmlStreamReader(pomFile))); } catch (IOException e) { throw new RuntimeException("Failed to read POM file: " + pomFile, e); } catch (XmlPullParserException e) { diff --git a/pom.xml b/pom.xml index e1a25e2..14a9a9d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven maven-parent - 42 + 43 @@ -64,8 +64,7 @@ under the License. - 3.2.5 - 3.9.6 + 3.9.9 plugin-testing-archives/LATEST 8 2023-11-07T21:58:12Z