[MPLUGIN-176] helpmojo: Use Java 5 generics in generated help mojo
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1050558 13f79535-47bb-0310-9956-ffa450edef68master
parent
9ea26413d9
commit
a30e8eabbd
|
|
@ -53,6 +53,14 @@ public class HelpGeneratorMojo
|
|||
*/
|
||||
private String helpPackageName;
|
||||
|
||||
/**
|
||||
* Generate Java 5 sources.
|
||||
*
|
||||
* @parameter expression="${useJava5}" default-value="false"
|
||||
* @since 2.7
|
||||
*/
|
||||
private boolean useJava5;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected File getOutputDirectory()
|
||||
{
|
||||
|
|
@ -62,7 +70,7 @@ public class HelpGeneratorMojo
|
|||
/** {@inheritDoc} */
|
||||
protected Generator createGenerator()
|
||||
{
|
||||
return new PluginHelpGenerator().setHelpPackageName( helpPackageName );
|
||||
return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseJava5( useJava5 );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public class PluginHelpGenerator
|
|||
private static final String HELP_GOAL = "help";
|
||||
|
||||
private String helpPackageName;
|
||||
|
||||
/** Flag to indicate if the generated help mojo should use Java 5 features */
|
||||
private boolean useJava5;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
|
|
@ -127,7 +130,7 @@ public class PluginHelpGenerator
|
|||
try
|
||||
{
|
||||
writer = new OutputStreamWriter( new FileOutputStream( helpClass ), request.getEncoding() );
|
||||
writeClass( writer, pluginDescriptor, helpDescriptor );
|
||||
writeClass( writer, pluginDescriptor, helpDescriptor, useJava5 );
|
||||
writer.flush();
|
||||
}
|
||||
finally
|
||||
|
|
@ -142,6 +145,12 @@ public class PluginHelpGenerator
|
|||
return this;
|
||||
}
|
||||
|
||||
public PluginHelpGenerator setUseJava5( boolean useJava5 )
|
||||
{
|
||||
this.useJava5 = useJava5;
|
||||
return this;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Private methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -278,9 +287,10 @@ public class PluginHelpGenerator
|
|||
* @param writer not null
|
||||
* @param pluginDescriptor not null
|
||||
* @param helpDescriptor not null
|
||||
* @param useJava5 If the generated code should use Java5 features
|
||||
* @throws IOException if any
|
||||
*/
|
||||
private static void writeClass( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor )
|
||||
private static void writeClass( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor, boolean useJava5 )
|
||||
throws IOException
|
||||
{
|
||||
String packageName = "";
|
||||
|
|
@ -303,6 +313,11 @@ public class PluginHelpGenerator
|
|||
|
||||
writeMojoJavadoc( writer, pluginDescriptor, helpDescriptor );
|
||||
|
||||
if ( useJava5 )
|
||||
{
|
||||
writer.write( "@SuppressWarnings( \"all\" )" + LS );
|
||||
}
|
||||
|
||||
writer.write( "public class " + simpleName + LS );
|
||||
writer.write( " extends AbstractMojo" + LS );
|
||||
writer.write( "{" + LS );
|
||||
|
|
|
|||
Loading…
Reference in New Issue