This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch MPH-193 in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git
commit 31a2678b85cb3e367551fa37d857f0f2e8131bae Author: Michael Osipov <[email protected]> AuthorDate: Fri Oct 18 08:55:13 2024 +0200 [MPH-193] Document charset for evaluate goal file output This closes #123 --- .../org/apache/maven/plugins/help/AbstractEffectiveMojo.java | 6 +++--- .../java/org/apache/maven/plugins/help/AbstractHelpMojo.java | 11 ++++++----- src/main/java/org/apache/maven/plugins/help/DescribeMojo.java | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java index fab3e6b..ff4e29e 100644 --- a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; @@ -32,7 +33,6 @@ import java.util.List; import java.util.Properties; import java.util.Set; -import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.XMLWriter; import org.codehaus.plexus.util.xml.XmlWriterUtil; import org.jdom2.Document; @@ -49,7 +49,7 @@ import org.jdom2.output.XMLOutputter; */ public abstract class AbstractEffectiveMojo extends AbstractHelpMojo { /** - * Utility method to write an XML content in a given file. + * Utility method to write an XML content to a given file. * * @param output is the wanted output file. * @param content contains the XML content to be written to the file. @@ -62,7 +62,7 @@ public abstract class AbstractEffectiveMojo extends AbstractHelpMojo { } output.getParentFile().mkdirs(); - try (Writer out = WriterFactory.newXmlWriter(output)) { + try (Writer out = Files.newBufferedWriter(output.toPath())) { out.write(content); } } diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java b/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java index 0439b83..b0135dd 100644 --- a/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java @@ -21,6 +21,7 @@ package org.apache.maven.plugins.help; import java.io.File; import java.io.IOException; import java.io.Writer; +import java.nio.file.Files; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; @@ -33,7 +34,6 @@ import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingRequest; -import org.codehaus.plexus.util.WriterFactory; import org.eclipse.aether.RepositoryException; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -81,7 +81,8 @@ public abstract class AbstractHelpMojo extends AbstractMojo { protected MavenSession session; /** - * Optional parameter to write the output of this help in a given file, instead of writing to the console. + * Optional parameter to write the output of this help to a given file using UTF-8 encoding, + * instead of writing to the console. * <br> * <b>Note</b>: Could be a relative path. */ @@ -89,7 +90,7 @@ public abstract class AbstractHelpMojo extends AbstractMojo { protected File output; /** - * Utility method to write a content in a given file. + * Utility method to write a content to a given file. * * @param output is the wanted output file. * @param content contains the content to be written to the file. @@ -101,7 +102,7 @@ public abstract class AbstractHelpMojo extends AbstractMojo { } /** - * Utility method to write a content in a given file. + * Utility method to write a content to a given file. * * @param output is the wanted output file. * @param content contains the content to be written to the file. @@ -113,7 +114,7 @@ public abstract class AbstractHelpMojo extends AbstractMojo { } output.getParentFile().mkdirs(); - try (Writer out = WriterFactory.newPlatformWriter(output)) { + try (Writer out = Files.newBufferedWriter(output.toPath())) { out.write(content); } } diff --git a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java index 7cf0ec8..19a8118 100644 --- a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java +++ b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java @@ -240,7 +240,7 @@ public class DescribeMojo extends AbstractHelpMojo { // ---------------------------------------------------------------------- /** - * Method to write the Mojo description into the output file + * Method to write the Mojo description to the output file * * @param descriptionBuffer contains the description to be written to the file * @throws MojoExecutionException if any
