From 5b9427333ab4b7b48b297a8b9a4158688211f14a Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 10 Sep 2024 18:38:44 +0200 Subject: [PATCH] [MGPG-141] Remove use of deprecated classes (#117) The MGPG-138 also updated plexus-utils to 4.0.1 and plexus-xml to 3.0.1. --- https://issues.apache.org/jira/browse/MGPG-141 --- .../org/apache/maven/plugins/gpg/GpgSigner.java | 2 +- .../maven/plugins/gpg/SignAndDeployFileMojo.java | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java index b4f9e08..98d5331 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java +++ b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java @@ -74,7 +74,7 @@ protected void generateSignatureForFile(File file, File signature) throws MojoEx throw new MojoExecutionException("Could not determine gpg version"); } - getLog().debug(gpgVersion.toString()); + getLog().debug("GPG Version: " + gpgVersion); if (args != null) { for (String arg : args) { diff --git a/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java b/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java index e4853fc..db4e09c 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/gpg/SignAndDeployFileMojo.java @@ -21,8 +21,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.Reader; -import java.io.Writer; +import java.io.InputStream; +import java.io.OutputStream; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -46,9 +46,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.artifact.Artifact; @@ -401,8 +399,8 @@ private void processModel(Model model) { * @throws MojoExecutionException If the file doesn't exist of cannot be read. */ private Model readModel(File pomFile) throws MojoExecutionException { - try (Reader reader = ReaderFactory.newXmlReader(pomFile)) { - return new MavenXpp3Reader().read(reader); + try (InputStream inputStream = Files.newInputStream(pomFile.toPath())) { + return new MavenXpp3Reader().read(inputStream); } catch (FileNotFoundException e) { throw new MojoExecutionException("POM not found " + pomFile, e); } catch (IOException e) { @@ -425,8 +423,8 @@ private File generatePomFile() throws MojoExecutionException { File tempFile = Files.createTempFile("mvndeploy", ".pom").toFile(); tempFile.deleteOnExit(); - try (Writer fw = WriterFactory.newXmlWriter(tempFile)) { - new MavenXpp3Writer().write(fw, model); + try (OutputStream outputStream = Files.newOutputStream(tempFile.toPath())) { + new MavenXpp3Writer().write(outputStream, model); } return tempFile;