--- maven-plugin-tools-3.6.0/maven-plugin-plugin/src/main/filtered-resources/META-INF/maven/org.apache.maven.plugins/maven-plugin-plugin/plugin-help.xml 1970-01-01 01:00:00.000000000 +0100 +++ maven-plugin-tools-3.6.0/maven-plugin-plugin/src/main/filtered-resources/META-INF/maven/org.apache.maven.plugins/maven-plugin-plugin/plugin-help.xml 2019-11-25 11:03:12.945643770 +0100 @@ -0,0 +1,385 @@ + + + ${project.name} + ${project.description} + ${project.groupId} + ${project.artifactId} + ${project.version} + plugin + + + addPluginArtifactMetadata + Inject any plugin-specific artifact metadata to the project's artifact, for subsequent installation and deployment. It is used: +1. to add the latest metadata (which is plugin-specific) for shipping alongside the plugin's artifact +2. to define plugin mapping in the group + + false + true + false + false + false + true + package + org.apache.maven.plugin.plugin.metadata.AddPluginArtifactMetadataMojo + java + per-lookup + once-per-session + 2.0 + true + + + goalPrefix + java.lang.String + false + true + Inject any plugin-specific artifact metadata to the project's artifact, for subsequent installation and deployment. It is used: +1. to add the latest metadata (which is plugin-specific) for shipping alongside the plugin's artifact +2. to define plugin mapping in the group + + + + skip + boolean + 2.8 + false + true + Inject any plugin-specific artifact metadata to the project's artifact, for subsequent installation and deployment. It is used: +1. to add the latest metadata (which is plugin-specific) for shipping alongside the plugin's artifact +2. to define plugin mapping in the group + + + + + ${maven.plugin.skip} + + + + descriptor + Generate a plugin descriptor. + +Note: Since 3.0, for Java plugin annotations support, default phase defined by this goal is after the 'compilation' of any scripts. This doesn't override the default binding coded at generate-resources phase in Maven core. + + runtime + false + true + false + false + false + true + process-classes + org.apache.maven.plugin.plugin.DescriptorGeneratorMojo + java + per-lookup + once-per-session + 2.0 + true + + + encoding + java.lang.String + 2.5 + false + true + Abstract class for this Plugin. + + + extractors + java.util.Set + false + true + Abstract class for this Plugin. + + + goalPrefix + java.lang.String + false + true + Abstract class for this Plugin. + + + mojoDependencies + java.util.List + 3.5 + false + true + Abstract class for this Plugin. + + + outputDirectory + java.io.File + false + true + Generate a plugin descriptor. + +Note: Since 3.0, for Java plugin annotations support, default phase defined by this goal is after the 'compilation' of any scripts. This doesn't override the default binding coded at generate-resources phase in Maven core. + + + + packagingTypes + java.util.List + 3.3 + false + true + Abstract class for this Plugin. + + + skip + boolean + 2.8 + false + true + Abstract class for this Plugin. + + + skipDescriptor + boolean + 2.6 + false + true + Generate a plugin descriptor. + +Note: Since 3.0, for Java plugin annotations support, default phase defined by this goal is after the 'compilation' of any scripts. This doesn't override the default binding coded at generate-resources phase in Maven core. + + + + skipErrorNoDescriptorsFound + boolean + 3.0 + false + true + Abstract class for this Plugin. + + + + ${encoding} + + ${maven.plugin.skip} + + ${maven.plugin.skipErrorNoDescriptorsFound} + + + + help + Display help information on maven-plugin-plugin. +Call mvn plugin:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. + false + false + false + false + false + true + org.apache.maven.plugin.plugin.HelpMojo + java + per-lookup + once-per-session + true + + + detail + boolean + false + true + Display help information on maven-plugin-plugin. +Call mvn plugin:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. + + + goal + java.lang.String + false + true + Display help information on maven-plugin-plugin. +Call mvn plugin:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. + + + indentSize + int + false + true + Display help information on maven-plugin-plugin. +Call mvn plugin:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. + + + lineLength + int + false + true + Display help information on maven-plugin-plugin. +Call mvn plugin:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. + + + + ${detail} + ${goal} + ${indentSize} + ${lineLength} + + + + helpmojo + Generates a HelpMojo class. + compile + false + true + false + false + false + true + generate-sources + org.apache.maven.plugin.plugin.HelpGeneratorMojo + java + per-lookup + once-per-session + 2.4 + true + + + encoding + java.lang.String + 2.5 + false + true + Abstract class for this Plugin. + + + extractors + java.util.Set + false + true + Abstract class for this Plugin. + + + goalPrefix + java.lang.String + false + true + Abstract class for this Plugin. + + + helpPackageName + java.lang.String + 2.6 + false + true + Generates a HelpMojo class. + + + mojoDependencies + java.util.List + 3.5 + false + true + Abstract class for this Plugin. + + + outputDirectory + java.io.File + false + true + Generates a HelpMojo class. + + + packagingTypes + java.util.List + 3.3 + false + true + Abstract class for this Plugin. + + + skip + boolean + 2.8 + false + true + Abstract class for this Plugin. + + + skipErrorNoDescriptorsFound + boolean + 3.0 + false + true + Abstract class for this Plugin. + + + + ${encoding} + + ${maven.plugin.skip} + ${maven.plugin.skipErrorNoDescriptorsFound} + + + + report + Generates the Plugin's documentation report: plugin-info.html plugin overview page, and one goal-mojo.html per goal. + false + true + false + false + false + true + process-classes + org.apache.maven.plugin.plugin.PluginReport + java + per-lookup + once-per-session + 2.0 + true + + + encoding + java.lang.String + 2.7 + false + true + Generates the Plugin's documentation report: plugin-info.html plugin overview page, and one goal-mojo.html per goal. + + + goalPrefix + java.lang.String + 2.4 + false + true + Generates the Plugin's documentation report: plugin-info.html plugin overview page, and one goal-mojo.html per goal. + + + outputDirectory + java.io.File + false + true + Generates the Plugin's documentation report: plugin-info.html plugin overview page, and one goal-mojo.html per goal. + + + requirements + org.apache.maven.plugin.plugin.Requirements + false + true + Generates the Plugin's documentation report: plugin-info.html plugin overview page, and one goal-mojo.html per goal. + + + skip + boolean + 2.8 + false + true + Generates the Plugin's documentation report: plugin-info.html plugin overview page, and one goal-mojo.html per goal. + + + skipReport + boolean + 2.8 + false + true + Generates the Plugin's documentation report: plugin-info.html plugin overview page, and one goal-mojo.html per goal. + + + + ${encoding} + ${goalPrefix} + + ${maven.plugin.skip} + ${maven.plugin.report.skip} + + + + --- maven-plugin-tools-3.6.0/maven-plugin-plugin/src/main/filtered-resources/META-INF/maven/plugin.xml 1970-01-01 01:00:00.000000000 +0100 +++ maven-plugin-tools-3.6.0/maven-plugin-plugin/src/main/filtered-resources/META-INF/maven/plugin.xml 2019-11-25 11:05:03.978261704 +0100 @@ -0,0 +1,1062 @@ + + + ${project.name} + ${project.description} + ${project.groupId} + ${project.artifactId} + ${project.version} + plugin + false + true + + + addPluginArtifactMetadata + Inject any plugin-specific +<a href="/ref/current/maven-repository-metadata/repository-metadata.html">artifact metadata</a> to the project's +artifact, for subsequent installation and deployment. +It is used: +<ol> +<li>to add the <code>latest</code> metadata (which is plugin-specific) for shipping alongside the plugin's + artifact</li> +<li>to define plugin mapping in the group</li> +</ol> + false + true + false + false + false + true + package + org.apache.maven.plugin.plugin.metadata.AddPluginArtifactMetadataMojo + java + per-lookup + once-per-session + 2.0 + true + + + goalPrefix + java.lang.String + false + true + Inject any plugin-specific +<a href="/ref/current/maven-repository-metadata/repository-metadata.html">artifact metadata</a> to the project's +artifact, for subsequent installation and deployment. +It is used: +<ol> +<li>to add the <code>latest</code> metadata (which is plugin-specific) for shipping alongside the plugin's + artifact</li> +<li>to define plugin mapping in the group</li> +</ol> + + + project + org.apache.maven.project.MavenProject + false + false + Inject any plugin-specific +<a href="/ref/current/maven-repository-metadata/repository-metadata.html">artifact metadata</a> to the project's +artifact, for subsequent installation and deployment. +It is used: +<ol> +<li>to add the <code>latest</code> metadata (which is plugin-specific) for shipping alongside the plugin's + artifact</li> +<li>to define plugin mapping in the group</li> +</ol> + + + skip + boolean + 2.8 + false + true + Inject any plugin-specific +<a href="/ref/current/maven-repository-metadata/repository-metadata.html">artifact metadata</a> to the project's +artifact, for subsequent installation and deployment. +It is used: +<ol> +<li>to add the <code>latest</code> metadata (which is plugin-specific) for shipping alongside the plugin's + artifact</li> +<li>to define plugin mapping in the group</li> +</ol> + + + + + ${maven.plugin.skip} + + + + descriptor + <p> +Generate a plugin descriptor. +</p> +<p> +<b>Note:</b> Since 3.0, for Java plugin annotations support, +default <a href="http://maven.apache.org/ref/current/maven-core/lifecycles.html">phase</a> +defined by this goal is after the "compilation" of any scripts. This doesn't override +<a href="/ref/current/maven-core/default-bindings.html#Bindings_for_maven-plugin_packaging">the default binding coded +at generate-resources phase</a> in Maven core. +</p> + runtime + false + true + false + false + false + true + process-classes + org.apache.maven.plugin.plugin.DescriptorGeneratorMojo + java + per-lookup + once-per-session + 2.0 + true + + + dependencies + java.util.Set + 3.0 + true + false + Abstract class for this Plugin. + + + encoding + java.lang.String + 2.5 + false + true + Abstract class for this Plugin. + + + extractors + java.util.Set + false + true + Abstract class for this Plugin. + + + goalPrefix + java.lang.String + false + true + Abstract class for this Plugin. + + + local + org.apache.maven.artifact.repository.ArtifactRepository + 3.0 + true + false + Abstract class for this Plugin. + + + mojoDependencies + java.util.List + 3.5 + false + true + Abstract class for this Plugin. + + + outputDirectory + java.io.File + false + true + <p> +Generate a plugin descriptor. +</p> +<p> +<b>Note:</b> Since 3.0, for Java plugin annotations support, +default <a href="http://maven.apache.org/ref/current/maven-core/lifecycles.html">phase</a> +defined by this goal is after the "compilation" of any scripts. This doesn't override +<a href="/ref/current/maven-core/default-bindings.html#Bindings_for_maven-plugin_packaging">the default binding coded +at generate-resources phase</a> in Maven core. +</p> + + + packagingTypes + java.util.List + 3.3 + false + true + Abstract class for this Plugin. + + + project + org.apache.maven.project.MavenProject + false + false + Abstract class for this Plugin. + + + remoteRepos + java.util.List + 3.0 + true + false + Abstract class for this Plugin. + + + skip + boolean + 2.8 + false + true + Abstract class for this Plugin. + + + skipDescriptor + boolean + 2.6 + false + true + <p> +Generate a plugin descriptor. +</p> +<p> +<b>Note:</b> Since 3.0, for Java plugin annotations support, +default <a href="http://maven.apache.org/ref/current/maven-core/lifecycles.html">phase</a> +defined by this goal is after the "compilation" of any scripts. This doesn't override +<a href="/ref/current/maven-core/default-bindings.html#Bindings_for_maven-plugin_packaging">the default binding coded +at generate-resources phase</a> in Maven core. +</p> + + + skipErrorNoDescriptorsFound + boolean + 3.0 + false + true + Abstract class for this Plugin. + + + + + ${encoding} + + + + + ${maven.plugin.skip} + + ${maven.plugin.skipErrorNoDescriptorsFound} + + + + org.apache.maven.tools.plugin.scanner.MojoScanner + mojoScanner + + + + + help + Display help information on maven-plugin-plugin.<br> +Call <code>mvn plugin:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details. + false + false + false + false + false + true + org.apache.maven.plugin.plugin.HelpMojo + java + per-lookup + once-per-session + true + + + detail + boolean + false + true + Display help information on maven-plugin-plugin.<br> +Call <code>mvn plugin:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details. + + + goal + java.lang.String + false + true + Display help information on maven-plugin-plugin.<br> +Call <code>mvn plugin:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details. + + + indentSize + int + false + true + Display help information on maven-plugin-plugin.<br> +Call <code>mvn plugin:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details. + + + lineLength + int + false + true + Display help information on maven-plugin-plugin.<br> +Call <code>mvn plugin:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</code> to display parameter details. + + + + ${detail} + ${goal} + ${indentSize} + ${lineLength} + + + + helpmojo + Generates a <code>HelpMojo</code> class. + compile + false + true + false + false + false + true + generate-sources + org.apache.maven.plugin.plugin.HelpGeneratorMojo + java + per-lookup + once-per-session + 2.4 + true + + + dependencies + java.util.Set + 3.0 + true + false + Abstract class for this Plugin. + + + encoding + java.lang.String + 2.5 + false + true + Abstract class for this Plugin. + + + extractors + java.util.Set + false + true + Abstract class for this Plugin. + + + goalPrefix + java.lang.String + false + true + Abstract class for this Plugin. + + + helpPackageName + java.lang.String + 2.6 + false + true + Generates a <code>HelpMojo</code> class. + + + local + org.apache.maven.artifact.repository.ArtifactRepository + 3.0 + true + false + Abstract class for this Plugin. + + + mojoDependencies + java.util.List + 3.5 + false + true + Abstract class for this Plugin. + + + outputDirectory + java.io.File + false + true + Generates a <code>HelpMojo</code> class. + + + packagingTypes + java.util.List + 3.3 + false + true + Abstract class for this Plugin. + + + project + org.apache.maven.project.MavenProject + false + false + Abstract class for this Plugin. + + + remoteRepos + java.util.List + 3.0 + true + false + Abstract class for this Plugin. + + + skip + boolean + 2.8 + false + true + Abstract class for this Plugin. + + + skipErrorNoDescriptorsFound + boolean + 3.0 + false + true + Abstract class for this Plugin. + + + + + ${encoding} + + + + + ${maven.plugin.skip} + ${maven.plugin.skipErrorNoDescriptorsFound} + + + + org.apache.maven.tools.plugin.scanner.MojoScanner + mojoScanner + + + org.codehaus.plexus.velocity.VelocityComponent + velocity + + + + + report + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + false + true + false + false + false + true + process-classes + org.apache.maven.plugin.plugin.PluginReport + java + per-lookup + once-per-session + 2.0 + true + + + dependencies + java.util.Set + 3.0 + true + false + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + encoding + java.lang.String + 2.7 + false + true + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + goalPrefix + java.lang.String + 2.4 + false + true + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + inputEncoding + java.lang.String + false + false + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + local + org.apache.maven.artifact.repository.ArtifactRepository + 3.0 + true + false + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + outputDirectory + java.io.File + false + true + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + outputEncoding + java.lang.String + false + false + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + pluginXmlFile + java.io.File + 3.5.1 + true + false + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + project + org.apache.maven.project.MavenProject + false + false + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + remoteRepos + java.util.List + 3.0 + true + false + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + requirements + org.apache.maven.plugin.plugin.Requirements + false + true + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + skip + boolean + 2.8 + false + true + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + skipReport + boolean + 2.8 + false + true + Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page, +and one <code><i>goal</i>-mojo.html</code> per goal. + + + + + ${encoding} + ${goalPrefix} + ${encoding} + + + ${outputEncoding} + + + + ${maven.plugin.skip} + ${maven.plugin.report.skip} + + + + org.apache.maven.tools.plugin.scanner.MojoScanner + mojoScanner + + + org.apache.maven.execution.RuntimeInformation + rtInfo + + + org.apache.maven.doxia.siterenderer.Renderer + siteRenderer + + + + + + + org.apache.maven + maven-compat + jar + 3.0 + + + org.apache.maven + maven-settings + jar + 3.6.2 + + + org.apache.maven + maven-model-builder + jar + 3.6.2 + + + org.apache.maven + maven-builder-support + jar + 3.6.2 + + + javax.inject + javax.inject + jar + 1 + + + org.eclipse.sisu + org.eclipse.sisu.inject + jar + 0.3.3 + + + javax.enterprise + cdi-api + jar + 1.1 + + + javax.el + javax.el-api + jar + 3.0.0 + + + org.jboss.spec.javax.interceptor + jboss-interceptors-api_1.2_spec + jar + any + + + org.codehaus.plexus + plexus-interpolation + jar + 1.25 + + + org.apache.maven.wagon + wagon-provider-api + jar + 3.3.3 + + + org.apache.maven + maven-resolver-provider + jar + 3.6.2 + + + org.apache.maven.resolver + maven-resolver-spi + jar + 1.4.1 + + + org.slf4j + slf4j-api + jar + 1.7.25 + + + org.apache.maven + maven-core + jar + 3.0 + + + com.google.inject + guice + jar + 4.2.1 + + + aopalliance + aopalliance + jar + 1.0 + + + cglib + cglib + jar + 3.2.0 + + + org.apache.maven.resolver + maven-resolver-api + jar + 1.4.1 + + + org.apache.maven.resolver + maven-resolver-util + jar + 1.4.1 + + + org.apache.maven.resolver + maven-resolver-impl + jar + 1.4.1 + + + org.codehaus.plexus + plexus-component-annotations + jar + 1.5.5 + + + org.apache.maven + maven-settings-builder + jar + 3.6.2 + + + org.sonatype.plexus + plexus-sec-dispatcher + jar + 1.4 + + + org.sonatype.plexus + plexus-cipher + jar + 1.4 + + + org.eclipse.sisu + org.eclipse.sisu.plexus + jar + 0.3.3 + + + org.apache.maven.plugin-tools + maven-plugin-tools-api + jar + 3.6.0 + + + org.apache.maven.plugin-tools + maven-plugin-tools-generators + jar + 3.6.0 + + + net.sf.jtidy + jtidy + jar + r938 + + + xerces + dom3-xml-apis + jar + 1.0 + + + org.ow2.asm + asm-commons + jar + 7.0 + + + org.ow2.asm + asm-tree + jar + 7.2 + + + org.ow2.asm + asm-analysis + jar + 7.2 + + + org.ow2.asm + asm + jar + 7.0 + + + org.apache.maven.plugin-tools + maven-plugin-tools-java + jar + 3.6.0 + + + com.thoughtworks.qdox + qdox + jar + 2.0-M5 + + + org.apache.maven.plugin-tools + maven-plugin-tools-annotations + jar + 3.6.0 + + + org.codehaus.plexus + plexus-archiver + jar + 3.6.0 + + + org.codehaus.plexus + plexus-io + jar + 3.2.0 + + + org.apache.commons + commons-compress + jar + 1.19 + + + org.tukaani + xz + jar + 1.8 + + + org.apache.maven.plugin-tools + maven-plugin-annotations + jar + 3.6.0 + + + org.apache.maven.doxia + doxia-sink-api + jar + 1.4 + + + org.apache.maven.doxia + doxia-logging-api + jar + 1.7 + + + org.apache.maven.doxia + doxia-site-renderer + jar + 1.4 + + + org.apache.maven.doxia + doxia-decoration-model + jar + 1.7.5 + + + commons-collections + commons-collections + jar + 3.2.1 + + + org.apache.maven.doxia + doxia-core + jar + 1.7 + + + org.apache.httpcomponents + httpcore + jar + 4.0.1 + + + org.apache.httpcomponents + httpclient + jar + 4.0.2 + + + commons-logging + commons-logging + jar + any + + + commons-codec + commons-codec + jar + any + + + xmlunit + xmlunit + jar + 1.5 + + + org.apache.maven.doxia + doxia-module-xhtml + jar + 1.7 + + + org.codehaus.plexus + plexus-i18n + jar + 1.0-beta-7 + + + org.apache.commons + commons-lang3 + jar + 3.5 + + + org.apache.maven.doxia + doxia-skin-model + jar + 1.7.5 + + + org.apache.maven + maven-plugin-api + jar + 3.0 + + + org.codehaus.plexus + plexus-classworlds + jar + 2.6.0 + + + org.apache.maven + maven-model + jar + 3.0 + + + org.apache.maven + maven-repository-metadata + jar + 3.0 + + + org.apache.maven + maven-artifact + jar + 3.0 + + + org.apache.maven.reporting + maven-reporting-impl + jar + 2.3 + + + org.apache.maven.shared + maven-shared-utils + jar + 3.2.0 + + + commons-io + commons-io + jar + 2.5 + + + org.apache.maven.reporting + maven-reporting-api + jar + 3.0 + + + org.codehaus.plexus + plexus-utils + jar + 3.0.20 + + + org.codehaus.plexus + plexus-velocity + jar + 1.1.8 + + + org.codehaus.plexus + plexus-container-default + jar + SYSTEM + + + org.apache.xbean + xbean-reflect + jar + SYSTEM + + + com.google.guava + guava + jar + 20.0 + + + junit + junit + jar + SYSTEM + + + org.hamcrest + hamcrest-core + jar + 1.3 + + + org.apache.velocity + velocity + jar + 1.7 + + + commons-lang + commons-lang + jar + 2.4 + + + --- maven-plugin-tools-3.6.0/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpMojo.java 1970-01-01 01:00:00.000000000 +0100 +++ maven-plugin-tools-3.6.0/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpMojo.java 2019-11-25 11:01:29.241066576 +0100 @@ -0,0 +1,458 @@ + +package org.apache.maven.plugin.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * Display help information on maven-plugin-plugin.
+ * Call 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 ); + + //plugin + String goalPrefix = getValue( plugin, "goalPrefix" ); + + Node mojos1 = getSingleChild( plugin, "mojos" ); + + List mojos = findNamedChild( mojos1, "mojo" ); + + if ( goal == null || goal.length() <= 0 ) + { + append( sb, "This plugin has " + mojos.size() + ( mojos.size() > 1 ? " goals:" : " goal:" ), 0 ); + append( sb, "", 0 ); + } + + for ( Node mojo : mojos ) + { + writeGoal( sb, goalPrefix, (Element) mojo ); + } + + if ( getLog().isInfoEnabled() ) + { + getLog().info( sb.toString() ); + } + } + + + private static boolean isNotEmpty( String string ) + { + return string != null && string.length() > 0; + } + + private String getValue( Node node, String elementName ) + throws MojoExecutionException + { + return getSingleChild( node, elementName ).getTextContent(); + } + + private Node getSingleChild( Node node, String elementName ) + throws MojoExecutionException + { + List namedChild = findNamedChild( node, elementName ); + if ( namedChild.isEmpty() ) + { + throw new MojoExecutionException( "Could not find " + elementName + " in plugin-help.xml" ); + } + if ( namedChild.size() > 1 ) + { + throw new MojoExecutionException( "Multiple " + elementName + " in plugin-help.xml" ); + } + return namedChild.get( 0 ); + } + + private List findNamedChild( Node node, String elementName ) + { + List result = new ArrayList(); + NodeList childNodes = node.getChildNodes(); + for ( int i = 0; i < childNodes.getLength(); i++ ) + { + Node item = childNodes.item( i ); + if ( elementName.equals( item.getNodeName() ) ) + { + result.add( item ); + } + } + return result; + } + + private Node findSingleChild( Node node, String elementName ) + throws MojoExecutionException + { + List elementsByTagName = findNamedChild( node, elementName ); + if ( elementsByTagName.isEmpty() ) + { + return null; + } + if ( elementsByTagName.size() > 1 ) + { + throw new MojoExecutionException( "Multiple " + elementName + "in plugin-help.xml" ); + } + return elementsByTagName.get( 0 ); + } + + private void writeGoal( StringBuilder sb, String goalPrefix, Element mojo ) + throws MojoExecutionException + { + String mojoGoal = getValue( mojo, "goal" ); + Node configurationElement = findSingleChild( mojo, "configuration" ); + Node description = findSingleChild( mojo, "description" ); + if ( goal == null || goal.length() <= 0 || mojoGoal.equals( goal ) ) + { + append( sb, goalPrefix + ":" + mojoGoal, 0 ); + Node deprecated = findSingleChild( mojo, "deprecated" ); + if ( ( deprecated != null ) && isNotEmpty( deprecated.getTextContent() ) ) + { + append( sb, "Deprecated. " + deprecated.getTextContent(), 1 ); + if ( detail && description != null ) + { + append( sb, "", 0 ); + append( sb, description.getTextContent(), 1 ); + } + } + else if ( description != null ) + { + append( sb, description.getTextContent(), 1 ); + } + append( sb, "", 0 ); + + if ( detail ) + { + Node parametersNode = getSingleChild( mojo, "parameters" ); + List parameters = findNamedChild( parametersNode, "parameter" ); + append( sb, "Available parameters:", 1 ); + append( sb, "", 0 ); + + for ( Node parameter : parameters ) + { + writeParameter( sb, parameter, configurationElement ); + } + } + } + } + + private void writeParameter( StringBuilder sb, Node parameter, Node configurationElement ) + throws MojoExecutionException + { + String parameterName = getValue( parameter, "name" ); + String parameterDescription = getValue( parameter, "description" ); + + Element fieldConfigurationElement = null; + if ( configurationElement != null ) + { + fieldConfigurationElement = (Element) findSingleChild( configurationElement, parameterName ); + } + + String parameterDefaultValue = ""; + if ( fieldConfigurationElement != null && fieldConfigurationElement.hasAttribute( "default-value" ) ) + { + parameterDefaultValue = " (Default: " + fieldConfigurationElement.getAttribute( "default-value" ) + ")"; + } + append( sb, parameterName + parameterDefaultValue, 2 ); + Node deprecated = findSingleChild( parameter, "deprecated" ); + if ( ( deprecated != null ) && isNotEmpty( deprecated.getTextContent() ) ) + { + append( sb, "Deprecated. " + deprecated.getTextContent(), 3 ); + append( sb, "", 0 ); + } + append( sb, parameterDescription, 3 ); + if ( "true".equals( getValue( parameter, "required" ) ) ) + { + append( sb, "Required: Yes", 3 ); + } + if ( ( fieldConfigurationElement != null ) && isNotEmpty( fieldConfigurationElement.getTextContent() ) ) + { + String property = getPropertyFromExpression( fieldConfigurationElement.getTextContent() ); + append( sb, "User property: " + property, 3 ); + } + + append( sb, "", 0 ); + } + + /** + *

Repeat a String n times to form a new string.

+ * + * @param str String to repeat + * @param repeat number of times to repeat str + * @return String with repeated String + * @throws NegativeArraySizeException if 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 List toLines( String text, int indent, int indentSize, int lineLength ) + { + List lines = new ArrayList(); + + String ind = repeat( "\t", indent ); + + String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); + + for ( String plainLine : plainLines ) + { + toLines( lines, ind + plainLine, indentSize, lineLength ); + } + + return lines; + } + + /** + * Adds the specified line to the output sequence, performing line wrapping if necessary. + * + * @param lines The sequence of display lines, must not be null. + * @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( List lines, String line, int indentSize, int lineLength ) + { + int lineIndent = getIndentLevel( line ); + StringBuilder buf = new StringBuilder( 256 ); + + String[] tokens = line.split( " +" ); + + for ( String token : tokens ) + { + if ( buf.length() > 0 ) + { + if ( buf.length() + token.length() >= lineLength ) + { + lines.add( buf.toString() ); + buf.setLength( 0 ); + buf.append( repeat( " ", lineIndent * indentSize ) ); + } + else + { + buf.append( ' ' ); + } + } + + for ( int j = 0; j < token.length(); j++ ) + { + char c = token.charAt( j ); + if ( c == '\t' ) + { + buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); + } + else if ( c == '\u00A0' ) + { + buf.append( ' ' ); + } + else + { + buf.append( c ); + } + } + } + lines.add( buf.toString() ); + } + + /** + * Gets the indentation level of the specified line. + * + * @param line The line whose indentation level should be retrieved, must not be null. + * @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; + } +}