Class PluginHelpGenerator

  • All Implemented Interfaces:
    Generator, org.codehaus.plexus.logging.LogEnabled

    public class PluginHelpGenerator
    extends org.codehaus.plexus.logging.AbstractLogEnabled
    implements Generator
    Generates an HelpMojo class from help-class-source.vm template. The generated mojo reads help content from META-INF/maven/${groupId}/${artifactId}/plugin-help.xml resource, which is generated by this PluginDescriptorGenerator.

    Notice that the help mojo source needs to be generated before compilation, but when Java annotations are used, plugin descriptor content is available only after compilation (detecting annotations in .class files): help mojo source can be generated with empty package only (and no plugin descriptor available yet), then needs to be updated after compilation - through rewriteHelpMojo(PluginToolsRequest, Log) which is called from plugin descriptor XML generation.

    Since:
    2.4
    • Constructor Summary

      Constructors 
      Constructor Description
      PluginHelpGenerator()
      Default constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute​(java.io.File destinationDirectory, PluginToolsRequest request)
      Execute the generation for a given plugin descriptor.
      private java.lang.String getHelpClassSources​(java.lang.String pluginHelpPath, org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)  
      private java.lang.String getImplementation​(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)  
      (package private) static java.lang.String getPluginHelpPath​(org.apache.maven.project.MavenProject mavenProject)  
      org.codehaus.plexus.velocity.VelocityComponent getVelocityComponent()  
      private static java.lang.String rewriteHelpClassToMojoPackage​(PluginToolsRequest request, java.io.File destinationDirectory, org.apache.maven.plugin.logging.Log log)  
      (package private) static void rewriteHelpMojo​(PluginToolsRequest request, org.apache.maven.plugin.logging.Log log)
      Rewrite Help Mojo to match actual Mojos package name if it was not available at source generation time.
      PluginHelpGenerator setHelpPackageName​(java.lang.String helpPackageName)  
      PluginHelpGenerator setVelocityComponent​(org.codehaus.plexus.velocity.VelocityComponent velocityComponent)  
      private static void updateHelpMojoDescriptor​(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor, java.lang.String helpMojoImplementation)  
      private void writeHelpPropertiesFile​(PluginToolsRequest request, java.io.File destinationDirectory)
      Write help properties files for later use to eventually rewrite Help Mojo.
      • Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled

        enableLogging, getLogger, setupLogger, setupLogger, setupLogger
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • HELP_MOJO_CLASS_NAME

        private static final java.lang.String HELP_MOJO_CLASS_NAME
        Default generated class name
        See Also:
        Constant Field Values
      • HELP_PROPERTIES_FILENAME

        private static final java.lang.String HELP_PROPERTIES_FILENAME
        Help properties file, to store data about generated source.
        See Also:
        Constant Field Values
      • HELP_GOAL

        private static final java.lang.String HELP_GOAL
        Default goal
        See Also:
        Constant Field Values
      • helpPackageName

        private java.lang.String helpPackageName
      • useAnnotations

        private boolean useAnnotations
      • velocityComponent

        private org.codehaus.plexus.velocity.VelocityComponent velocityComponent
    • Constructor Detail

      • PluginHelpGenerator

        public PluginHelpGenerator()
        Default constructor
    • Method Detail

      • setHelpPackageName

        public PluginHelpGenerator setHelpPackageName​(java.lang.String helpPackageName)
      • getVelocityComponent

        public org.codehaus.plexus.velocity.VelocityComponent getVelocityComponent()
      • setVelocityComponent

        public PluginHelpGenerator setVelocityComponent​(org.codehaus.plexus.velocity.VelocityComponent velocityComponent)
      • getHelpClassSources

        private java.lang.String getHelpClassSources​(java.lang.String pluginHelpPath,
                                                     org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • getImplementation

        private java.lang.String getImplementation​(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)
        Parameters:
        pluginDescriptor - The descriptor of the plugin for which to generate a help goal, must not be null.
        Returns:
        The implementation.
      • writeHelpPropertiesFile

        private void writeHelpPropertiesFile​(PluginToolsRequest request,
                                             java.io.File destinationDirectory)
                                      throws GeneratorException
        Write help properties files for later use to eventually rewrite Help Mojo.
        Parameters:
        request -
        Throws:
        GeneratorException
      • getPluginHelpPath

        static java.lang.String getPluginHelpPath​(org.apache.maven.project.MavenProject mavenProject)
      • rewriteHelpMojo

        static void rewriteHelpMojo​(PluginToolsRequest request,
                                    org.apache.maven.plugin.logging.Log log)
                             throws GeneratorException
        Rewrite Help Mojo to match actual Mojos package name if it was not available at source generation time. This is used at descriptor generation time.
        Parameters:
        request -
        Throws:
        GeneratorException
      • updateHelpMojoDescriptor

        private static void updateHelpMojoDescriptor​(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor,
                                                     java.lang.String helpMojoImplementation)