[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;
|
private String helpPackageName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate Java 5 sources.
|
||||||
|
*
|
||||||
|
* @parameter expression="${useJava5}" default-value="false"
|
||||||
|
* @since 2.7
|
||||||
|
*/
|
||||||
|
private boolean useJava5;
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
protected File getOutputDirectory()
|
protected File getOutputDirectory()
|
||||||
{
|
{
|
||||||
|
|
@ -62,7 +70,7 @@ public class HelpGeneratorMojo
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
protected Generator createGenerator()
|
protected Generator createGenerator()
|
||||||
{
|
{
|
||||||
return new PluginHelpGenerator().setHelpPackageName( helpPackageName );
|
return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseJava5( useJava5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@ public class PluginHelpGenerator
|
||||||
|
|
||||||
private String helpPackageName;
|
private String helpPackageName;
|
||||||
|
|
||||||
|
/** Flag to indicate if the generated help mojo should use Java 5 features */
|
||||||
|
private boolean useJava5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
|
|
@ -127,7 +130,7 @@ public class PluginHelpGenerator
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writer = new OutputStreamWriter( new FileOutputStream( helpClass ), request.getEncoding() );
|
writer = new OutputStreamWriter( new FileOutputStream( helpClass ), request.getEncoding() );
|
||||||
writeClass( writer, pluginDescriptor, helpDescriptor );
|
writeClass( writer, pluginDescriptor, helpDescriptor, useJava5 );
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
@ -142,6 +145,12 @@ public class PluginHelpGenerator
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PluginHelpGenerator setUseJava5( boolean useJava5 )
|
||||||
|
{
|
||||||
|
this.useJava5 = useJava5;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Private methods
|
// Private methods
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
@ -278,9 +287,10 @@ public class PluginHelpGenerator
|
||||||
* @param writer not null
|
* @param writer not null
|
||||||
* @param pluginDescriptor not null
|
* @param pluginDescriptor not null
|
||||||
* @param helpDescriptor not null
|
* @param helpDescriptor not null
|
||||||
|
* @param useJava5 If the generated code should use Java5 features
|
||||||
* @throws IOException if any
|
* @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
|
throws IOException
|
||||||
{
|
{
|
||||||
String packageName = "";
|
String packageName = "";
|
||||||
|
|
@ -303,6 +313,11 @@ public class PluginHelpGenerator
|
||||||
|
|
||||||
writeMojoJavadoc( writer, pluginDescriptor, helpDescriptor );
|
writeMojoJavadoc( writer, pluginDescriptor, helpDescriptor );
|
||||||
|
|
||||||
|
if ( useJava5 )
|
||||||
|
{
|
||||||
|
writer.write( "@SuppressWarnings( \"all\" )" + LS );
|
||||||
|
}
|
||||||
|
|
||||||
writer.write( "public class " + simpleName + LS );
|
writer.write( "public class " + simpleName + LS );
|
||||||
writer.write( " extends AbstractMojo" + LS );
|
writer.write( " extends AbstractMojo" + LS );
|
||||||
writer.write( "{" + LS );
|
writer.write( "{" + LS );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue