Skip to content

Commit bf04d07

Browse files
committed
[MPLUGIN-469] Omit empty line in generated help goal output if plugin description is empty
1 parent ee9b35d commit bf04d07

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/expected-help.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ help-deprecated-annotation-only:test
2020
Parameter description in javadoc.
2121

2222
undocumentedParam
23-
2423
Required: Yes
2524
User property: test.undocumented

maven-plugin-plugin/src/it/help-basic-jdk11/expected-help.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ help-jdk11:test
2020
This parameter is deprecated.
2121

2222
undocumentedParam
23-
2423
Required: Yes
2524
User property: test.undocumented

maven-plugin-plugin/src/it/help-basic/expected-help.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ help:test
2020
This parameter is deprecated.
2121

2222
undocumentedParam
23-
2423
Required: Yes
2524
User property: test.undocumented

maven-plugin-tools-generators/src/main/resources/help-class-source-v4.vm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ public class HelpMojo
298298
append( sb, "Deprecated. " + deprecated.getTextContent(), 3 );
299299
append( sb, "", 0 );
300300
}
301-
append( sb, parameterDescription, 3 );
301+
if ( isNotEmpty( parameterDescription ) ) {
302+
append( sb, parameterDescription, 3 );
303+
}
302304
if ( "true".equals( getValue( parameter, "required" ) ) )
303305
{
304306
append( sb, "Required: Yes", 3 );
@@ -449,7 +451,7 @@ public class HelpMojo
449451
}
450452
return level;
451453
}
452-
454+
453455
private static String getPropertyFromExpression( String expression )
454456
{
455457
if ( expression != null && expression.startsWith( "${" ) && expression.endsWith( "}" )

maven-plugin-tools-generators/src/main/resources/help-class-source.vm

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
## to you under the Apache License, Version 2.0 (the
66
## "License"); you may not use this file except in compliance
77
## with the License. You may obtain a copy of the License at
8-
##
8+
##
99
## http://www.apache.org/licenses/LICENSE-2.0
10-
##
10+
##
1111
## Unless required by applicable law or agreed to in writing,
1212
## software distributed under the License is distributed on an
1313
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -43,7 +43,7 @@ import java.util.List;
4343
* Display help information on ${artifactId}.<br>
4444
* Call <code>mvn ${goalPrefix}:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details.
4545
* @author maven-plugin-tools
46-
#if ( !$useAnnotations )
46+
#if ( !$useAnnotations )
4747
* @goal help
4848
* @requiresProject false
4949
* @threadSafe
@@ -58,47 +58,47 @@ public class HelpMojo
5858
/**
5959
* If <code>true</code>, display all settable properties for each goal.
6060
*
61-
#if ( !$useAnnotations )
61+
#if ( !$useAnnotations )
6262
* @parameter property="detail" default-value="false"
6363
#end
6464
*/
65-
#if ( $useAnnotations )
65+
#if ( $useAnnotations )
6666
@Parameter( property = "detail", defaultValue = "false" )
6767
#end
6868
private boolean detail;
6969

7070
/**
7171
* The name of the goal for which to show help. If unspecified, all goals will be displayed.
7272
*
73-
#if ( !$useAnnotations )
73+
#if ( !$useAnnotations )
7474
* @parameter property="goal"
7575
#end
7676
*/
77-
#if ( $useAnnotations )
77+
#if ( $useAnnotations )
7878
@Parameter( property = "goal" )
79-
#end
79+
#end
8080
private java.lang.String goal;
8181

8282
/**
8383
* The maximum length of a display line, should be positive.
8484
*
85-
#if ( !$useAnnotations )
85+
#if ( !$useAnnotations )
8686
* @parameter property="lineLength" default-value="80"
8787
#end
8888
*/
89-
#if ( $useAnnotations )
89+
#if ( $useAnnotations )
9090
@Parameter( property = "lineLength", defaultValue = "80" )
9191
#end
9292
private int lineLength;
9393

9494
/**
9595
* The number of spaces per indentation level, should be positive.
9696
*
97-
#if ( !$useAnnotations )
97+
#if ( !$useAnnotations )
9898
* @parameter property="indentSize" default-value="2"
9999
#end
100100
*/
101-
#if ( $useAnnotations )
101+
#if ( $useAnnotations )
102102
@Parameter( property = "indentSize", defaultValue = "2" )
103103
#end
104104
private int indentSize;
@@ -327,7 +327,9 @@ public class HelpMojo
327327
append( sb, "Deprecated. " + deprecated.getTextContent(), 3 );
328328
append( sb, "", 0 );
329329
}
330-
append( sb, parameterDescription, 3 );
330+
if ( isNotEmpty( parameterDescription ) ) {
331+
append( sb, parameterDescription, 3 );
332+
}
331333
if ( "true".equals( getValue( parameter, "required" ) ) )
332334
{
333335
append( sb, "Required: Yes", 3 );
@@ -478,7 +480,7 @@ public class HelpMojo
478480
}
479481
return level;
480482
}
481-
483+
482484
private static String getPropertyFromExpression( String expression )
483485
{
484486
if ( expression != null && expression.startsWith( "${" ) && expression.endsWith( "}" )

0 commit comments

Comments
 (0)