This is an automated email from the ASF dual-hosted git repository.
slawekjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 1e2c74c Encapsulate deprecated MessageUtils usage in private methods
(#463)
1e2c74c is described below
commit 1e2c74c790194cedd6a2b87871879e0d4a00ce84
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Sat Nov 14 14:32:11 2026 +0100
Encapsulate deprecated MessageUtils usage in private methods (#463)
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../apache/maven/plugins/help/DescribeMojo.java | 37 ++++++++++------------
.../maven/plugins/help/EffectivePomMojo.java | 30 ++++++++++++------
2 files changed, 38 insertions(+), 29 deletions(-)
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 d1e4ba6..a728ecb 100644
--- a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
@@ -57,7 +57,6 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.reporting.MavenReport;
-import org.apache.maven.shared.utils.logging.MessageUtils;
import org.apache.maven.tools.plugin.generator.HtmlToPlainTextConverter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.artifact.Artifact;
@@ -418,16 +417,12 @@ public class DescribeMojo extends AbstractHelpMojo {
name = pd.getId();
}
}
- append(buffer, "Name", MessageUtils.buffer().strong(name).build(), 0);
+ append(buffer, "Name", buffer().strong(name).build(), 0);
appendAsParagraph(buffer, "Description",
toDescription(pd.getDescription()), 0);
append(buffer, "Group Id", pd.getGroupId(), 0);
append(buffer, "Artifact Id", pd.getArtifactId(), 0);
append(buffer, "Version", pd.getVersion(), 0);
- append(
- buffer,
- "Goal Prefix",
- MessageUtils.buffer().strong(pd.getGoalPrefix()).build(),
- 0);
+ append(buffer, "Goal Prefix",
buffer().strong(pd.getGoalPrefix()).build(), 0);
buffer.append(LS);
List<MojoDescriptor> mojos = pd.getMojos();
@@ -490,7 +485,7 @@ public class DescribeMojo extends AbstractHelpMojo {
*/
private void describeMojoGuts(MojoDescriptor md, StringBuilder buffer,
boolean fullDescription)
throws MojoFailureException, MojoExecutionException {
- append(buffer,
MessageUtils.buffer().strong(md.getFullGoalName()).build(), 0);
+ append(buffer, buffer().strong(md.getFullGoalName()).build(), 0);
// indent 1
appendAsParagraph(buffer, "Description",
toDescription(md.getDescription()), 1);
@@ -501,10 +496,7 @@ public class DescribeMojo extends AbstractHelpMojo {
}
if (deprecation != null) {
- append(
- buffer,
- MessageUtils.buffer().warning("Deprecated. " +
deprecation).build(),
- 1);
+ append(buffer, buffer().warning("Deprecated. " +
deprecation).build(), 1);
}
if (isReportGoal(md)) {
@@ -590,11 +582,11 @@ public class DescribeMojo extends AbstractHelpMojo {
}
if (defaultVal != null && !defaultVal.isEmpty()) {
- defaultVal = " (Default: " +
MessageUtils.buffer().strong(defaultVal) + ")";
+ defaultVal = " (Default: " +
buffer().strong(defaultVal).build() + ")";
} else {
defaultVal = "";
}
- append(buffer, MessageUtils.buffer().strong(parameter.getName()) +
defaultVal, 2);
+ append(buffer, buffer().strong(parameter.getName()).build() +
defaultVal, 2);
String alias = parameter.getAlias();
if (!(alias == null || alias.isEmpty())) {
@@ -629,12 +621,7 @@ public class DescribeMojo extends AbstractHelpMojo {
}
if (deprecation != null) {
- append(
- buffer,
- MessageUtils.buffer()
- .warning("Deprecated. " + deprecation)
- .build(),
- 3);
+ append(buffer, buffer().warning("Deprecated. " +
deprecation).build(), 3);
}
}
}
@@ -949,6 +936,16 @@ public class DescribeMojo extends AbstractHelpMojo {
return "(no description available)";
}
+ /**
+ * Creates a new message buffer. Encapsulates the deprecated {@code
MessageUtils} and {@code MessageBuilder} usage.
+ *
+ * @return a new message buffer
+ */
+ @SuppressWarnings("deprecation")
+ private static org.apache.maven.shared.utils.logging.MessageBuilder
buffer() {
+ return org.apache.maven.shared.utils.logging.MessageUtils.buffer();
+ }
+
/**
* Class to wrap Plugin information.
*/
diff --git a/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
b/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
index 14bea42..6a1738d 100644
--- a/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
@@ -38,7 +38,6 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilder;
-import org.apache.maven.shared.utils.logging.MessageUtils;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
import org.codehaus.plexus.util.xml.XmlWriterUtil;
@@ -138,20 +137,33 @@ public class EffectivePomMojo extends
AbstractEffectiveMojo {
getLog().info("Effective-POM written to: " + output);
} else {
- if (MessageUtils.isColorEnabled()) {
- // add color to comments
- String comment =
MessageUtils.buffer().project("<!--.-->").build();
- int dotIndex = comment.indexOf(".");
- String commentStart = comment.substring(0, dotIndex);
- String commentEnd = comment.substring(dotIndex + 1);
- effectivePom = effectivePom.replace("<!--",
commentStart).replace("-->", commentEnd);
- }
+ effectivePom = colorizeComments(effectivePom);
getLog().info(LS + "Effective POMs, after inheritance,
interpolation, and profiles are applied:" + LS + LS
+ effectivePom + LS);
}
}
+ /**
+ * Adds color to XML comments if color output is enabled. Encapsulates the
deprecated {@code MessageUtils} usage.
+ *
+ * @param effectivePom the effective POM content
+ * @return the effective POM content with colored comments
+ */
+ @SuppressWarnings("deprecation")
+ private static String colorizeComments(String effectivePom) {
+ if
(!org.apache.maven.shared.utils.logging.MessageUtils.isColorEnabled()) {
+ return effectivePom;
+ }
+ String comment =
org.apache.maven.shared.utils.logging.MessageUtils.buffer()
+ .project("<!--.-->")
+ .build();
+ int dotIndex = comment.indexOf(".");
+ String commentStart = comment.substring(0, dotIndex);
+ String commentEnd = comment.substring(dotIndex + 1);
+ return effectivePom.replace("<!--", commentStart).replace("-->",
commentEnd);
+ }
+
/**
* Determines if all effective POMs of all the projects in the reactor
should be written. When this goal is started
* on the command-line, it is always the case. However, when it is bound
to a phase in the lifecycle, it is only the