removed dead code

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1337712 13f79535-47bb-0310-9956-ffa450edef68
master
Herve Boutemy 2012-05-12 22:41:56 +00:00
parent b7864f235b
commit e42b381a7f
5 changed files with 37 additions and 203 deletions

View File

@ -54,14 +54,6 @@ 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;
/** /**
* Velocity component. * Velocity component.
* *
@ -84,8 +76,7 @@ public class HelpGeneratorMojo
*/ */
protected Generator createGenerator() protected Generator createGenerator()
{ {
return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseJava5( return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity );
useJava5 ).setVelocityComponent( this.velocity );
} }
/** /**

View File

@ -1,4 +1,5 @@
package org.apache.maven.tools.plugin.generator; package org.apache.maven.tools.plugin.generator;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file

View File

@ -194,83 +194,6 @@ public class PluginDescriptorGenerator
} }
} }
/**
* Creates a minimalistic mojo descriptor for the generated help goal.
*
* @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be
* <code>null</code>.
* @return The mojo descriptor for the generated help goal, never <code>null</code>.
*/
private MojoDescriptor makeHelpDescriptor( PluginDescriptor pluginDescriptor, String packageName )
{
MojoDescriptor descriptor = new MojoDescriptor();
descriptor.setPluginDescriptor( pluginDescriptor );
descriptor.setLanguage( "java" );
descriptor.setGoal( "help" );
if ( StringUtils.isEmpty( packageName ) )
{
packageName = PluginUtils.discoverPackageName( pluginDescriptor );
}
if ( StringUtils.isNotEmpty( packageName ) )
{
descriptor.setImplementation( packageName + '.' + "HelpMojo" );
}
else
{
descriptor.setImplementation( "HelpMojo" );
}
descriptor.setDescription(
"Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre> mvn "
+ descriptor.getFullGoalName()
+ " -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details." );
try
{
Parameter param = new Parameter();
param.setName( "detail" );
param.setType( "boolean" );
param.setDescription( "If <code>true</code>, display all settable properties for each goal." );
param.setDefaultValue( "false" );
param.setExpression( "${detail}" );
descriptor.addParameter( param );
param = new Parameter();
param.setName( "goal" );
param.setType( "java.lang.String" );
param.setDescription(
"The name of the goal for which to show help." + " If unspecified, all goals will be displayed." );
param.setExpression( "${goal}" );
descriptor.addParameter( param );
param = new Parameter();
param.setName( "lineLength" );
param.setType( "int" );
param.setDescription( "The maximum length of a display line, should be positive." );
param.setDefaultValue( "80" );
param.setExpression( "${lineLength}" );
descriptor.addParameter( param );
param = new Parameter();
param.setName( "indentSize" );
param.setType( "int" );
param.setDescription( "The number of spaces per indentation level, should be positive." );
param.setDefaultValue( "2" );
param.setExpression( "${indentSize}" );
descriptor.addParameter( param );
}
catch ( Exception e )
{
throw new RuntimeException( "Failed to setup parameters for help goal", e );
}
return descriptor;
}
protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w ) protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w )
{ {
processMojoDescriptor( mojoDescriptor, w, false ); processMojoDescriptor( mojoDescriptor, w, false );

View File

@ -20,7 +20,6 @@ package org.apache.maven.tools.plugin.generator;
*/ */
import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.PluginToolsRequest; import org.apache.maven.tools.plugin.PluginToolsRequest;
@ -55,11 +54,6 @@ public class PluginHelpGenerator
extends AbstractLogEnabled extends AbstractLogEnabled
implements Generator implements Generator
{ {
/**
* Line separator
*/
private static final String LS = System.getProperty( "line.separator" );
/** /**
* Default generated class name * Default generated class name
*/ */
@ -72,11 +66,6 @@ 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;
private VelocityComponent velocityComponent; private VelocityComponent velocityComponent;
/** /**
@ -100,7 +89,7 @@ public class PluginHelpGenerator
{ {
PluginDescriptor pluginDescriptor = request.getPluginDescriptor(); PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
MojoDescriptor helpDescriptor = makeHelpDescriptor( pluginDescriptor ); String helpImplementation = getImplementation( pluginDescriptor );
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos(); List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
@ -110,14 +99,14 @@ public class PluginHelpGenerator
// Verify that no help goal already exists // Verify that no help goal already exists
for ( MojoDescriptor descriptor : mojoDescriptors ) for ( MojoDescriptor descriptor : mojoDescriptors )
{ {
if ( descriptor.getGoal().equals( helpDescriptor.getGoal() ) && !descriptor.getImplementation().equals( if ( HELP_GOAL.equals( descriptor.getGoal() )
helpDescriptor.getImplementation() ) ) && !descriptor.getImplementation().equals( helpImplementation ) )
{ {
if ( getLogger().isWarnEnabled() ) if ( getLogger().isWarnEnabled() )
{ {
getLogger().warn( "\n\nA help goal (" + descriptor.getImplementation() getLogger().warn( "\n\nA help goal (" + descriptor.getImplementation()
+ ") already exists in this plugin. SKIPPED THE " + ") already exists in this plugin. SKIPPED THE "
+ helpDescriptor.getImplementation() + " GENERATION.\n" ); + helpImplementation + " GENERATION.\n" );
} }
return; return;
@ -154,7 +143,7 @@ public class PluginHelpGenerator
throw new GeneratorException( e.getMessage(), e ); throw new GeneratorException( e.getMessage(), e );
} }
String sourcePath = helpDescriptor.getImplementation().replace( '.', File.separatorChar ) + ".java"; String sourcePath = helpImplementation.replace( '.', File.separatorChar ) + ".java";
File helpClass = new File( destinationDirectory, sourcePath ); File helpClass = new File( destinationDirectory, sourcePath );
helpClass.getParentFile().mkdirs(); helpClass.getParentFile().mkdirs();
@ -173,8 +162,6 @@ public class PluginHelpGenerator
{ {
IOUtil.close( writer ); IOUtil.close( writer );
} }
} }
public PluginHelpGenerator setHelpPackageName( String helpPackageName ) public PluginHelpGenerator setHelpPackageName( String helpPackageName )
@ -183,12 +170,6 @@ public class PluginHelpGenerator
return this; return this;
} }
public PluginHelpGenerator setUseJava5( boolean useJava5 )
{
this.useJava5 = useJava5;
return this;
}
public VelocityComponent getVelocityComponent() public VelocityComponent getVelocityComponent()
{ {
return velocityComponent; return velocityComponent;
@ -226,85 +207,22 @@ public class PluginHelpGenerator
velocityComponent.getEngine().evaluate( context, stringWriter, "", isReader ); velocityComponent.getEngine().evaluate( context, stringWriter, "", isReader );
return stringWriter.toString(); return stringWriter.toString();
} }
/** /**
* Creates a minimalistic mojo descriptor for the generated help goal.
*
* @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be * @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be
* <code>null</code>. * <code>null</code>.
* @return The mojo descriptor for the generated help goal, never <code>null</code>. * @return The implementation.
*/ */
private MojoDescriptor makeHelpDescriptor( PluginDescriptor pluginDescriptor ) private String getImplementation( PluginDescriptor pluginDescriptor )
{ {
MojoDescriptor descriptor = new MojoDescriptor();
descriptor.setPluginDescriptor( pluginDescriptor );
descriptor.setLanguage( "java" );
descriptor.setGoal( HELP_GOAL );
String packageName = helpPackageName; String packageName = helpPackageName;
if ( StringUtils.isEmpty( packageName ) ) if ( StringUtils.isEmpty( packageName ) )
{ {
packageName = PluginUtils.discoverPackageName( pluginDescriptor ); packageName = PluginUtils.discoverPackageName( pluginDescriptor );
} }
if ( StringUtils.isNotEmpty( packageName ) )
{
descriptor.setImplementation( packageName + '.' + HELP_MOJO_CLASS_NAME );
}
else
{
descriptor.setImplementation( HELP_MOJO_CLASS_NAME );
}
descriptor.setDescription( return StringUtils.isEmpty( packageName ) ? HELP_MOJO_CLASS_NAME : packageName + '.' + HELP_MOJO_CLASS_NAME;
"Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre> mvn "
+ descriptor.getFullGoalName()
+ " -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details." );
try
{
Parameter param = new Parameter();
param.setName( "detail" );
param.setType( "boolean" );
param.setDescription( "If <code>true</code>, display all settable properties for each goal." );
param.setDefaultValue( "false" );
param.setExpression( "${detail}" );
descriptor.addParameter( param );
param = new Parameter();
param.setName( "goal" );
param.setType( "java.lang.String" );
param.setDescription(
"The name of the goal for which to show help." + " If unspecified, all goals will be displayed." );
param.setExpression( "${goal}" );
descriptor.addParameter( param );
param = new Parameter();
param.setName( "lineLength" );
param.setType( "int" );
param.setDescription( "The maximum length of a display line, should be positive." );
param.setDefaultValue( "80" );
param.setExpression( "${lineLength}" );
descriptor.addParameter( param );
param = new Parameter();
param.setName( "indentSize" );
param.setType( "int" );
param.setDescription( "The number of spaces per indentation level, should be positive." );
param.setDefaultValue( "2" );
param.setExpression( "${indentSize}" );
descriptor.addParameter( param );
}
catch ( Exception e )
{
throw new RuntimeException( "Failed to setup parameters for help goal", e );
}
return descriptor;
} }
} }

View File

@ -15,7 +15,8 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
* Display help information on maven-plugin-plugin.<br/> Call <pre> mvn plugin:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details. * Display help information on maven-plugin-plugin.<br/>
* Call <pre> mvn plugin:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details.
* @author * @author
* @version * @version
* @goal help * @goal help
@ -53,33 +54,33 @@ public class HelpMojo
//@Parameter( expression = "${indentSize}", defaultValue = "2" ) //@Parameter( expression = "${indentSize}", defaultValue = "2" )
//private int indentSize; //private int indentSize;
/** /**
* If <code>true</code>, display all settable properties for each goal. * If <code>true</code>, display all settable properties for each goal.
* *
* @parameter expression="${detail}" default-value="false" * @parameter expression="${detail}" default-value="false"
*/ */
private boolean detail; private boolean detail;
/** /**
* The name of the goal for which to show help. If unspecified, all goals will be displayed. * The name of the goal for which to show help. If unspecified, all goals will be displayed.
* *
* @parameter expression="${goal}" * @parameter expression="${goal}"
*/ */
private java.lang.String goal; private java.lang.String goal;
/** /**
* The maximum length of a display line, should be positive. * The maximum length of a display line, should be positive.
* *
* @parameter expression="${lineLength}" default-value="80" * @parameter expression="${lineLength}" default-value="80"
*/ */
private int lineLength; private int lineLength;
/** /**
* The number of spaces per indentation level, should be positive. * The number of spaces per indentation level, should be positive.
* *
* @parameter expression="${indentSize}" default-value="2" * @parameter expression="${indentSize}" default-value="2"
*/ */
private int indentSize; private int indentSize;
// groupId/artifactId/version // groupId/artifactId/version
private String pluginDescriptorPath = "/${propertiesFilePath}"; private String pluginDescriptorPath = "/${propertiesFilePath}";
@ -88,7 +89,7 @@ private int indentSize;
throws MojoExecutionException throws MojoExecutionException
{ {
// olamy more than one pluginDescriptor in the classloader possible ? // olamy more than one pluginDescriptor in the classloader possible ?
getLog().debug("load pluginDescriptorPath: " + pluginDescriptorPath); getLog().debug( "load pluginDescriptorPath: " + pluginDescriptorPath );
InputStream is = getClass().getResourceAsStream( pluginDescriptorPath ); InputStream is = getClass().getResourceAsStream( pluginDescriptorPath );
try try
{ {