mvn plugin:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
++ * @author maven-plugin-tools
++ */
++@Mojo( name = "help", requiresProject = false, threadSafe = true )
++public class HelpMojo
++ extends AbstractMojo
++{
++ /**
++ * If true
, display all settable properties for each goal.
++ *
++ */
++ @Parameter( property = "detail", defaultValue = "false" )
++ private boolean detail;
++
++ /**
++ * The name of the goal for which to show help. If unspecified, all goals will be displayed.
++ *
++ */
++ @Parameter( property = "goal" )
++ private java.lang.String goal;
++
++ /**
++ * The maximum length of a display line, should be positive.
++ *
++ */
++ @Parameter( property = "lineLength", defaultValue = "80" )
++ private int lineLength;
++
++ /**
++ * The number of spaces per indentation level, should be positive.
++ *
++ */
++ @Parameter( property = "indentSize", defaultValue = "2" )
++ private int indentSize;
++
++ // groupId/artifactId/plugin-help.xml
++ private static final String PLUGIN_HELP_PATH =
++ "/META-INF/maven/org.apache.maven.plugins/maven-plugin-plugin/plugin-help.xml";
++
++ private static final int DEFAULT_LINE_LENGTH = 80;
++
++ private Document build()
++ throws MojoExecutionException
++ {
++ getLog().debug( "load plugin-help.xml: " + PLUGIN_HELP_PATH );
++ InputStream is = null;
++ try
++ {
++ is = getClass().getResourceAsStream( PLUGIN_HELP_PATH );
++ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
++ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
++ return dBuilder.parse( is );
++ }
++ catch ( IOException e )
++ {
++ throw new MojoExecutionException( e.getMessage(), e );
++ }
++ catch ( ParserConfigurationException e )
++ {
++ throw new MojoExecutionException( e.getMessage(), e );
++ }
++ catch ( SAXException e )
++ {
++ throw new MojoExecutionException( e.getMessage(), e );
++ }
++ finally
++ {
++ if ( is != null )
++ {
++ try
++ {
++ is.close();
++ }
++ catch ( IOException e )
++ {
++ throw new MojoExecutionException( e.getMessage(), e );
++ }
++ }
++ }
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ public void execute()
++ throws MojoExecutionException
++ {
++ if ( lineLength <= 0 )
++ {
++ getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." );
++ lineLength = DEFAULT_LINE_LENGTH;
++ }
++ if ( indentSize <= 0 )
++ {
++ getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." );
++ indentSize = 2;
++ }
++
++ Document doc = build();
++
++ StringBuilder sb = new StringBuilder();
++ Node plugin = getSingleChild( doc, "plugin" );
++
++
++ String name = getValue( plugin, "name" );
++ String version = getValue( plugin, "version" );
++ String id = getValue( plugin, "groupId" ) + ":" + getValue( plugin, "artifactId" ) + ":" + version;
++ if ( isNotEmpty( name ) && !name.contains( id ) )
++ {
++ append( sb, name + " " + version, 0 );
++ }
++ else
++ {
++ if ( isNotEmpty( name ) )
++ {
++ append( sb, name, 0 );
++ }
++ else
++ {
++ append( sb, id, 0 );
++ }
++ }
++ append( sb, getValue( plugin, "description" ), 1 );
++ append( sb, "", 0 );
++
++ //Repeat a String n
times to form a new string.
repeat < 0
++ * @throws NullPointerException if str is null
++ */
++ private static String repeat( String str, int repeat )
++ {
++ StringBuilder buffer = new StringBuilder( repeat * str.length() );
++
++ for ( int i = 0; i < repeat; i++ )
++ {
++ buffer.append( str );
++ }
++
++ return buffer.toString();
++ }
++
++ /**
++ * Append a description to the buffer by respecting the indentSize and lineLength parameters.
++ * Note: The last character is always a new line.
++ *
++ * @param sb The buffer to append the description, not null
.
++ * @param description The description, not null
.
++ * @param indent The base indentation level of each line, must not be negative.
++ */
++ private void append( StringBuilder sb, String description, int indent )
++ {
++ for ( String line : toLines( description, indent, indentSize, lineLength ) )
++ {
++ sb.append( line ).append( '\n' );
++ }
++ }
++
++ /**
++ * Splits the specified text into lines of convenient display length.
++ *
++ * @param text The text to split into lines, must not be null
.
++ * @param indent The base indentation level of each line, must not be negative.
++ * @param indentSize The size of each indentation, must not be negative.
++ * @param lineLength The length of the line, must not be negative.
++ * @return The sequence of display lines, never null
.
++ * @throws NegativeArraySizeException if indent < 0
++ */
++ private static Listnull
.
++ * @param line The line to add, must not be null
.
++ * @param indentSize The size of each indentation, must not be negative.
++ * @param lineLength The length of the line, must not be negative.
++ */
++ private static void toLines( Listnull
.
++ * @return The indentation level of the line.
++ */
++ private static int getIndentLevel( String line )
++ {
++ int level = 0;
++ for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
++ {
++ level++;
++ }
++ for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
++ {
++ if ( line.charAt( i ) == '\t' )
++ {
++ level++;
++ break;
++ }
++ }
++ return level;
++ }
++
++ private String getPropertyFromExpression( String expression )
++ {
++ if ( expression != null && expression.startsWith( "${" ) && expression.endsWith( "}" )
++ && !expression.substring( 2 ).contains( "${" ) )
++ {
++ // expression="${xxx}" -> property="xxx"
++ return expression.substring( 2, expression.length() - 1 );
++ }
++ // no property can be extracted
++ return null;
++ }
++}
diff --git a/maven-plugin-plugin-bootstrap.spec b/maven-plugin-plugin-bootstrap.spec
index e41a481..2c72a04 100644
--- a/maven-plugin-plugin-bootstrap.spec
+++ b/maven-plugin-plugin-bootstrap.spec
@@ -1,5 +1,5 @@
#
-# spec file for package maven-plugin-plugin
+# spec file for package maven
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
@@ -58,6 +58,7 @@ BuildRequires: xmvn-resolve
BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-tools-annotations)
BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-tools-java)
BuildRequires: mvn(org.apache.maven:maven-parent:pom:)
+BuildConflicts: java-devel >= 9
BuildArch: noarch
%description
@@ -124,6 +125,11 @@ artifact metadata and a generic help goal.
%pom_remove_dep :maven-plugin-descriptor
%pom_add_dep org.apache.maven:maven-compat
+# For some reason, this dependency is not generated by javapackages-local
+# and for some reasons if we give it a scope 'runtime' it works
+%pom_remove_dep :maven-plugin-annotations maven-plugin-plugin
+%pom_add_dep org.apache.maven.plugin-tools:maven-plugin-annotations:%{version}:runtime maven-plugin-plugin
+
%{mvn_package} :maven-plugin-tools __noinstall
%build