You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2012/05/13 00:41:56 UTC
svn commit: r1337712 - in /maven/plugin-tools/trunk:
maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/
maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/
maven-plugin-tools-api/src/main/resources/
Author: hboutemy
Date: Sat May 12 22:41:56 2012
New Revision: 1337712
URL: http://svn.apache.org/viewvc?rev=1337712&view=rev
Log:
removed dead code
Modified:
maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorException.java
maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/resources/help-class-source.vm
Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java?rev=1337712&r1=1337711&r2=1337712&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java Sat May 12 22:41:56 2012
@@ -55,14 +55,6 @@ public class HelpGeneratorMojo
private String helpPackageName;
/**
- * Generate Java 5 sources.
- *
- * @parameter expression="${useJava5}" default-value="false"
- * @since 2.7
- */
- private boolean useJava5;
-
- /**
* Velocity component.
*
* @component
@@ -84,8 +76,7 @@ public class HelpGeneratorMojo
*/
protected Generator createGenerator()
{
- return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseJava5(
- useJava5 ).setVelocityComponent( this.velocity );
+ return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity );
}
/**
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorException.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorException.java?rev=1337712&r1=1337711&r2=1337712&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorException.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorException.java Sat May 12 22:41:56 2012
@@ -1,4 +1,5 @@
package org.apache.maven.tools.plugin.generator;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java?rev=1337712&r1=1337711&r2=1337712&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Sat May 12 22:41:56 2012
@@ -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=<goal-name></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 )
{
processMojoDescriptor( mojoDescriptor, w, false );
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=1337712&r1=1337711&r2=1337712&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java Sat May 12 22:41:56 2012
@@ -20,7 +20,6 @@ package org.apache.maven.tools.plugin.ge
*/
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.project.MavenProject;
import org.apache.maven.tools.plugin.PluginToolsRequest;
@@ -56,11 +55,6 @@ public class PluginHelpGenerator
implements Generator
{
/**
- * Line separator
- */
- private static final String LS = System.getProperty( "line.separator" );
-
- /**
* Default generated class name
*/
private static final String HELP_MOJO_CLASS_NAME = "HelpMojo";
@@ -72,11 +66,6 @@ public class PluginHelpGenerator
private String helpPackageName;
- /**
- * Flag to indicate if the generated help mojo should use Java 5 features
- */
- private boolean useJava5;
-
private VelocityComponent velocityComponent;
/**
@@ -100,7 +89,7 @@ public class PluginHelpGenerator
{
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
- MojoDescriptor helpDescriptor = makeHelpDescriptor( pluginDescriptor );
+ String helpImplementation = getImplementation( pluginDescriptor );
@SuppressWarnings( "unchecked" )
List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
@@ -110,14 +99,14 @@ public class PluginHelpGenerator
// Verify that no help goal already exists
for ( MojoDescriptor descriptor : mojoDescriptors )
{
- if ( descriptor.getGoal().equals( helpDescriptor.getGoal() ) && !descriptor.getImplementation().equals(
- helpDescriptor.getImplementation() ) )
+ if ( HELP_GOAL.equals( descriptor.getGoal() )
+ && !descriptor.getImplementation().equals( helpImplementation ) )
{
if ( getLogger().isWarnEnabled() )
{
getLogger().warn( "\n\nA help goal (" + descriptor.getImplementation()
+ ") already exists in this plugin. SKIPPED THE "
- + helpDescriptor.getImplementation() + " GENERATION.\n" );
+ + helpImplementation + " GENERATION.\n" );
}
return;
@@ -154,7 +143,7 @@ public class PluginHelpGenerator
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 );
helpClass.getParentFile().mkdirs();
@@ -173,8 +162,6 @@ public class PluginHelpGenerator
{
IOUtil.close( writer );
}
-
-
}
public PluginHelpGenerator setHelpPackageName( String helpPackageName )
@@ -183,12 +170,6 @@ public class PluginHelpGenerator
return this;
}
- public PluginHelpGenerator setUseJava5( boolean useJava5 )
- {
- this.useJava5 = useJava5;
- return this;
- }
-
public VelocityComponent getVelocityComponent()
{
return velocityComponent;
@@ -226,85 +207,22 @@ public class PluginHelpGenerator
velocityComponent.getEngine().evaluate( context, stringWriter, "", isReader );
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
* <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;
if ( StringUtils.isEmpty( packageName ) )
{
packageName = PluginUtils.discoverPackageName( pluginDescriptor );
}
- if ( StringUtils.isNotEmpty( packageName ) )
- {
- descriptor.setImplementation( packageName + '.' + HELP_MOJO_CLASS_NAME );
- }
- else
- {
- descriptor.setImplementation( HELP_MOJO_CLASS_NAME );
- }
-
- descriptor.setDescription(
- "Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre> mvn "
- + descriptor.getFullGoalName()
- + " -Ddetail=true -Dgoal=<goal-name></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;
+ return StringUtils.isEmpty( packageName ) ? HELP_MOJO_CLASS_NAME : packageName + '.' + HELP_MOJO_CLASS_NAME;
}
}
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/resources/help-class-source.vm
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/resources/help-class-source.vm?rev=1337712&r1=1337711&r2=1337712&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/resources/help-class-source.vm (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/resources/help-class-source.vm Sat May 12 22:41:56 2012
@@ -15,7 +15,8 @@ import java.util.Iterator;
import java.util.List;
/**
- * Display help information on maven-plugin-plugin.<br/> Call <pre> mvn plugin:help -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details.
+ * Display help information on maven-plugin-plugin.<br/>
+ * Call <pre> mvn plugin:help -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details.
* @author
* @version
* @goal help
@@ -53,33 +54,33 @@ public class HelpMojo
//@Parameter( expression = "${indentSize}", defaultValue = "2" )
//private int indentSize;
-/**
- * If <code>true</code>, display all settable properties for each goal.
- *
- * @parameter expression="${detail}" default-value="false"
- */
-private boolean detail;
+ /**
+ * If <code>true</code>, display all settable properties for each goal.
+ *
+ * @parameter expression="${detail}" default-value="false"
+ */
+ private boolean detail;
-/**
- * The name of the goal for which to show help. If unspecified, all goals will be displayed.
- *
- * @parameter expression="${goal}"
- */
-private java.lang.String goal;
+ /**
+ * The name of the goal for which to show help. If unspecified, all goals will be displayed.
+ *
+ * @parameter expression="${goal}"
+ */
+ private java.lang.String goal;
-/**
- * The maximum length of a display line, should be positive.
- *
- * @parameter expression="${lineLength}" default-value="80"
- */
-private int lineLength;
+ /**
+ * The maximum length of a display line, should be positive.
+ *
+ * @parameter expression="${lineLength}" default-value="80"
+ */
+ private int lineLength;
-/**
- * The number of spaces per indentation level, should be positive.
- *
- * @parameter expression="${indentSize}" default-value="2"
- */
-private int indentSize;
+ /**
+ * The number of spaces per indentation level, should be positive.
+ *
+ * @parameter expression="${indentSize}" default-value="2"
+ */
+ private int indentSize;
// groupId/artifactId/version
private String pluginDescriptorPath = "/${propertiesFilePath}";
@@ -88,7 +89,7 @@ private int indentSize;
throws MojoExecutionException
{
// olamy more than one pluginDescriptor in the classloader possible ?
- getLog().debug("load pluginDescriptorPath: " + pluginDescriptorPath);
+ getLog().debug( "load pluginDescriptorPath: " + pluginDescriptorPath );
InputStream is = getClass().getResourceAsStream( pluginDescriptorPath );
try
{