You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2026/06/09 21:14:13 UTC
(maven-help-plugin) branch issue-367 created (now bc9402f)
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a change to branch issue-367
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git
at bc9402f Fix issue 367
This branch includes the following new commits:
new bc9402f Fix issue 367
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven-help-plugin) 01/01: Fix issue 367
Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch issue-367
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git
commit bc9402faf1c9d9d8175fb7045c6a4ffe4966542a
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Jun 9 23:13:53 2026 +0200
Fix issue 367
---
src/it/projects/describe-cmd/verify.groovy | 2 +-
.../apache/maven/plugins/help/DescribeMojo.java | 37 ++++++++++------------
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/src/it/projects/describe-cmd/verify.groovy b/src/it/projects/describe-cmd/verify.groovy
index b46af06..de3cdb4 100644
--- a/src/it/projects/describe-cmd/verify.groovy
+++ b/src/it/projects/describe-cmd/verify.groovy
@@ -22,7 +22,7 @@ def result = new File(basedir, 'result-deploy.txt').text;
def ls = System.getProperty( "line.separator" );
// used deprecated methods - FIXME in DescribeMojo
-if (mavenVersion.startsWith('4.') || mavenVersion.startsWith('3.10.')) {
+if (mavenVersion.startsWith('4.')) {
assert result.contains("'deploy' is a phase within the 'default' lifecycle, which has the following phases:")
} else {
assert result.contains("'deploy' is a phase corresponding to this plugin:" + ls +
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 9caa5cf..7f28a85 100644
--- a/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
@@ -29,7 +29,6 @@ import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -39,6 +38,8 @@ import org.apache.maven.lifecycle.DefaultLifecycles;
import org.apache.maven.lifecycle.Lifecycle;
import org.apache.maven.lifecycle.internal.MojoDescriptorCreator;
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
+import org.apache.maven.lifecycle.mapping.LifecycleMojo;
+import org.apache.maven.lifecycle.mapping.LifecyclePhase;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.plugin.MavenPluginManager;
@@ -496,7 +497,7 @@ public class DescribeMojo extends AbstractHelpMojo {
deprecation = NO_REASON;
}
- if (deprecation != null && !deprecation.isEmpty()) {
+ if (deprecation != null) {
append(
buffer,
MessageUtils.buffer().warning("Deprecated. " + deprecation).build(),
@@ -624,7 +625,7 @@ public class DescribeMojo extends AbstractHelpMojo {
deprecation = NO_REASON;
}
- if (deprecation != null && !deprecation.isEmpty()) {
+ if (deprecation != null) {
append(
buffer,
MessageUtils.buffer()
@@ -650,15 +651,15 @@ public class DescribeMojo extends AbstractHelpMojo {
throw new MojoExecutionException("The given phase '" + cmd + "' is an unknown phase.");
}
- // FIXME don't use a deprecated methods
- Map<String, String> defaultLifecyclePhases = lifecycleMappings
+ Map<String, LifecyclePhase> defaultLifecyclePhases = lifecycleMappings
.get(project.getPackaging())
.getLifecycles()
.get("default")
- .getPhases();
+ .getLifecyclePhases();
List<String> phases = lifecycle.getPhases();
- if (lifecycle.getDefaultPhases() == null) {
+ if (lifecycle.getDefaultLifecyclePhases() == null
+ || lifecycle.getDefaultLifecyclePhases().isEmpty()) {
descriptionBuffer.append("'").append(cmd);
descriptionBuffer
.append("' is a phase corresponding to this plugin:")
@@ -680,17 +681,13 @@ public class DescribeMojo extends AbstractHelpMojo {
descriptionBuffer.append(LS);
for (String key : phases) {
descriptionBuffer.append("* ").append(key).append(": ");
- String value = defaultLifecyclePhases.get(key);
- if (value != null && !value.isEmpty()) {
- for (StringTokenizer tok = new StringTokenizer(value, ","); tok.hasMoreTokens(); ) {
- descriptionBuffer.append(tok.nextToken().trim());
-
- if (!tok.hasMoreTokens()) {
- descriptionBuffer.append(LS);
- } else {
- descriptionBuffer.append(", ");
- }
- }
+ LifecyclePhase phase = defaultLifecyclePhases.get(key);
+ if (phase != null && !phase.getMojos().isEmpty()) {
+ descriptionBuffer
+ .append(phase.getMojos().stream()
+ .map(LifecycleMojo::getGoal)
+ .collect(Collectors.joining(", ")))
+ .append(LS);
} else {
descriptionBuffer.append(NOT_DEFINED).append(LS);
}
@@ -703,9 +700,9 @@ public class DescribeMojo extends AbstractHelpMojo {
for (String key : phases) {
descriptionBuffer.append("* ").append(key).append(": ");
- if (lifecycle.getDefaultPhases().get(key) != null) {
+ if (lifecycle.getDefaultLifecyclePhases().get(key) != null) {
descriptionBuffer
- .append(lifecycle.getDefaultPhases().get(key))
+ .append(lifecycle.getDefaultLifecyclePhases().get(key))
.append(LS);
} else {
descriptionBuffer.append(NOT_DEFINED).append(LS);