Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/it/projects/describe-cmd/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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.')) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting how without it #369 will pass ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no 3.10 on GH 😄

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 +
Expand Down
37 changes: 17 additions & 20 deletions src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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;
Expand All @@ -39,6 +38,8 @@
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;
Expand Down Expand Up @@ -496,7 +497,7 @@ private void describeMojoGuts(MojoDescriptor md, StringBuilder buffer, boolean f
deprecation = NO_REASON;
}

if (deprecation != null && !deprecation.isEmpty()) {
if (deprecation != null) {
append(
buffer,
MessageUtils.buffer().warning("Deprecated. " + deprecation).build(),
Expand Down Expand Up @@ -624,7 +625,7 @@ private void describeMojoParameters(MojoDescriptor md, StringBuilder buffer)
deprecation = NO_REASON;
}

if (deprecation != null && !deprecation.isEmpty()) {
if (deprecation != null) {
append(
buffer,
MessageUtils.buffer()
Expand All @@ -650,15 +651,15 @@ private boolean describeCommand(StringBuilder descriptionBuffer) throws MojoExec
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:")
Expand All @@ -680,17 +681,13 @@ private boolean describeCommand(StringBuilder descriptionBuffer) throws MojoExec
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);
}
Expand All @@ -703,9 +700,9 @@ private boolean describeCommand(StringBuilder descriptionBuffer) throws MojoExec

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))
Comment thread
cstamas marked this conversation as resolved.
.append(LS);
} else {
descriptionBuffer.append(NOT_DEFINED).append(LS);
Expand Down
Loading