You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2012/11/03 16:54:03 UTC

svn commit: r1405371 - in /maven/plugin-tools/trunk: maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/ maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/ maven-plugin-tools-generators/src/main/resources/

Author: rfscholte
Date: Sat Nov  3 15:54:02 2012
New Revision: 1405371

URL: http://svn.apache.org/viewvc?rev=1405371&view=rev
Log:
[MPLUGIN-231] Switch to plugin annotations for the generated help-mojo if the Maven Plugin depends on maven-plugin-annotations 

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-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
    maven/plugin-tools/trunk/maven-plugin-tools-generators/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=1405371&r1=1405370&r2=1405371&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 Nov  3 15:54:02 2012
@@ -32,12 +32,12 @@ import java.io.File;
 
 /**
  * Generates a <code>HelpMojo</code> class.
- *
+ * 
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
  * @version $Id$
  * @since 2.4
  */
-@Mojo( name = "helpmojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true )
+@Mojo( name = "helpmojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true /*, requiresDependencyResolution = ResolutionScope.COMPILE */ )
 public class HelpGeneratorMojo
     extends AbstractGeneratorMojo
 {
@@ -50,7 +50,7 @@ public class HelpGeneratorMojo
     /**
      * The name of the package for the generated <code>HelpMojo</code>. By default, the package will be calculated based
      * on the packages of the other plugin goals.
-     *
+     * 
      * @since 2.6
      */
     @Parameter
@@ -75,7 +75,7 @@ public class HelpGeneratorMojo
      */
     protected Generator createGenerator()
     {
-        return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity );
+        return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseAnnotations( project.getArtifactMap().containsKey( "org.apache.maven.plugin-tools:maven-plugin-annotations" ) ).setVelocityComponent( this.velocity );
     }
 
     /**

Modified: maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=1405371&r1=1405370&r2=1405371&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java Sat Nov  3 15:54:02 2012
@@ -88,6 +88,8 @@ public class PluginHelpGenerator
 
     private String helpPackageName;
 
+    private boolean useAnnotations;
+
     private VelocityComponent velocityComponent;
 
     /**
@@ -157,6 +159,12 @@ public class PluginHelpGenerator
         this.helpPackageName = helpPackageName;
         return this;
     }
+    
+    public PluginHelpGenerator setUseAnnotations( boolean useAnnotations )
+    {
+        this.useAnnotations = useAnnotations;
+        return this;
+    }
 
     public VelocityComponent getVelocityComponent()
     {
@@ -188,6 +196,7 @@ public class PluginHelpGenerator
         properties.put( "pluginHelpPath", pluginHelpPath );
         properties.put( "artifactId", pluginDescriptor.getArtifactId() );
         properties.put( "goalPrefix", pluginDescriptor.getGoalPrefix() );
+        properties.put( "useAnnotations", useAnnotations );
 
         StringWriter stringWriter = new StringWriter();
 

Modified: maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/help-class-source.vm
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/help-class-source.vm?rev=1405371&r1=1405370&r2=1405371&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/help-class-source.vm (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/help-class-source.vm Sat Nov  3 15:54:02 2012
@@ -34,33 +34,49 @@ public class HelpMojo
     /**
      * If <code>true</code>, display all settable properties for each goal.
      *
+#if ( !$useAnnotations )     
      * @parameter property="detail" default-value="false"
+#end
      */
-    //@Parameter( property = "detail", defaultValue = "false" )
+#if ( $useAnnotations )     
+    @Parameter( property = "detail", defaultValue = "false" )
+#end
     private boolean detail;
 
     /**
      * The name of the goal for which to show help. If unspecified, all goals will be displayed.
      *
+#if ( !$useAnnotations )     
      * @parameter property="goal"
+#end
      */
-    //@Parameter( property = "goal" )
+#if ( $useAnnotations )     
+    @Parameter( property = "goal" )
+#end    
     private java.lang.String goal;
 
     /**
      * The maximum length of a display line, should be positive.
      *
+#if ( !$useAnnotations )     
      * @parameter property="lineLength" default-value="80"
+#end
      */
-    //@Parameter( property = "lineLength", defaultValue = "80" )
+#if ( $useAnnotations )     
+    @Parameter( property = "lineLength", defaultValue = "80" )
+#end
     private int lineLength;
 
     /**
      * The number of spaces per indentation level, should be positive.
      *
+#if ( !$useAnnotations )     
      * @parameter property="indentSize" default-value="2"
+#end
      */
-    //@Parameter( property = "indentSize", defaultValue = "2" )
+#if ( $useAnnotations )     
+    @Parameter( property = "indentSize", defaultValue = "2" )
+#end
     private int indentSize;
 
     // groupId/artifactId/plugin-help.xml