Class PluginHelpGenerator
- java.lang.Object
-
- org.codehaus.plexus.logging.AbstractLogEnabled
-
- org.apache.maven.tools.plugin.generator.PluginHelpGenerator
-
- All Implemented Interfaces:
Generator
,org.codehaus.plexus.logging.LogEnabled
public class PluginHelpGenerator extends org.codehaus.plexus.logging.AbstractLogEnabled implements Generator
Generates anHelpMojo
class fromhelp-class-source.vm
template. The generated mojo reads help content fromMETA-INF/maven/${groupId}/${artifactId}/plugin-help.xml
resource, which is generated by thisPluginDescriptorGenerator
.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
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
HELP_GOAL
Default goalprivate static java.lang.String
HELP_MOJO_CLASS_NAME
Default generated class nameprivate static java.lang.String
HELP_PROPERTIES_FILENAME
Help properties file, to store data about generated source.private java.lang.String
helpPackageName
private boolean
useAnnotations
private org.codehaus.plexus.velocity.VelocityComponent
velocityComponent
-
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.
-
-
-
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
-
-
Method Detail
-
execute
public void execute(java.io.File destinationDirectory, PluginToolsRequest request) throws GeneratorException
Execute the generation for a given plugin descriptor.- Specified by:
execute
in interfaceGenerator
- Parameters:
destinationDirectory
- requiredrequest
- required- Throws:
GeneratorException
- if any
-
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 benull
.- 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
-
rewriteHelpClassToMojoPackage
private static java.lang.String rewriteHelpClassToMojoPackage(PluginToolsRequest request, java.io.File destinationDirectory, org.apache.maven.plugin.logging.Log log) throws GeneratorException
- Throws:
GeneratorException
-
updateHelpMojoDescriptor
private static void updateHelpMojoDescriptor(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor, java.lang.String helpMojoImplementation)
-
-