diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java b/src/main/java/org/apache/maven/plugins/help/EffectiveMojoUtils.java
similarity index 72%
rename from src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
rename to src/main/java/org/apache/maven/plugins/help/EffectiveMojoUtils.java
index 4bb3099..5a82b55 100644
--- a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/EffectiveMojoUtils.java
@@ -20,12 +20,9 @@
import javax.xml.XMLConstants;
-import java.io.File;
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;
@@ -33,10 +30,8 @@
import java.util.Properties;
import java.util.Set;
-import org.apache.maven.project.ProjectBuilder;
import org.codehaus.plexus.util.xml.XMLWriter;
import org.codehaus.plexus.util.xml.XmlWriterUtil;
-import org.eclipse.aether.RepositorySystem;
import org.jdom2.Document;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
@@ -44,42 +39,21 @@
import org.jdom2.output.XMLOutputter;
/**
- * Base class with common utilities to write effective Pom/settings.
+ * Utility class with common utilities to write effective Pom/settings.
*
* @author Vincent Siveton
* @since 2.1
*/
-public abstract class AbstractEffectiveMojo extends AbstractHelpMojo {
+public final class EffectiveMojoUtils {
- protected AbstractEffectiveMojo(ProjectBuilder projectBuilder, RepositorySystem repositorySystem) {
- super(projectBuilder, repositorySystem);
- }
-
- /**
- * 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.
- * @throws IOException if any
- * @see AbstractHelpMojo#writeFile(File, String) if encoding is null.
- */
- protected static void writeXmlFile(File output, String content) throws IOException {
- if (output == null) {
- return;
- }
-
- output.getParentFile().mkdirs();
- try (Writer out = Files.newBufferedWriter(output.toPath())) {
- out.write(content);
- }
- }
+ private EffectiveMojoUtils() {}
/**
* Write comments in the Effective POM/settings header.
*
* @param writer not null
*/
- protected static void writeHeader(XMLWriter writer) {
+ public static void writeHeader(XMLWriter writer) {
XmlWriterUtil.writeCommentLineBreak(writer);
XmlWriterUtil.writeComment(writer, " ");
XmlWriterUtil.writeComment(writer, "Generated by Maven Help Plugin");
@@ -91,10 +65,10 @@ protected static void writeHeader(XMLWriter writer) {
/**
* Write comments in a normalize way.
*
- * @param writer not null
+ * @param writer not null
* @param comment not null
*/
- protected static void writeComment(XMLWriter writer, String comment) {
+ public static void writeComment(XMLWriter writer, String comment) {
XmlWriterUtil.writeCommentLineBreak(writer);
XmlWriterUtil.writeComment(writer, " ");
XmlWriterUtil.writeComment(writer, comment);
@@ -103,12 +77,12 @@ protected static void writeComment(XMLWriter writer, String comment) {
}
/**
- * @param effectiveModel not null
- * @param encoding not null
+ * @param effectiveModel not null
+ * @param encoding not null
* @param omitDeclaration whether the XML declaration should be omitted from the effective pom
* @return pretty format of the xml or the original {@code effectiveModel} if an error occurred.
*/
- protected static String prettyFormat(String effectiveModel, String encoding, boolean omitDeclaration) {
+ public static String prettyFormat(String effectiveModel, String encoding, boolean omitDeclaration) {
SAXBuilder builder = new SAXBuilder();
builder.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
builder.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
@@ -132,14 +106,26 @@ protected static String prettyFormat(String effectiveModel, String encoding, boo
}
}
+ public static Properties sortProperties(Properties properties) {
+ Properties sortedProperties = new SortedProperties();
+ for (Object key : properties.keySet()) {
+ sortedProperties.put(key, properties.get(key));
+ }
+ return sortedProperties;
+ }
+
/**
* Properties which provides a sorted keySet().
*/
- protected static class SortedProperties extends Properties {
- /** serialVersionUID */
+ private static class SortedProperties extends Properties {
+ /**
+ * serialVersionUID
+ */
static final long serialVersionUID = -8985316072702233744L;
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public Set