maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1592217 - in /maven/plugin-tools/trunk: maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/ maven-plugin-plugin/src/it/java-basic-annotations/ maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apa...
Date Sat, 03 May 2014 15:20:29 GMT
Author: hboutemy
Date: Sat May  3 15:20:29 2014
New Revision: 1592217

URL: http://svn.apache.org/r1592217
Log:
[MPLUGIN-259] added @Parameter name="xxx" to set bean property name different from class'
field

Modified:
    maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/verify.groovy
    maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
    maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java
    maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
    maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/site/apt/index.apt
    maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoAnnotation.java
    maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
    maven/plugin-tools/trunk/maven-plugin-tools-java/src/site/apt/index.apt
    maven/plugin-tools/trunk/maven-plugin-tools-javadoc/src/main/java/org/apache/maven/tools/plugin/javadoc/MojoParameterFieldTaglet.java

Modified: maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
Sat May  3 15:20:29 2014
@@ -41,6 +41,12 @@ import java.lang.annotation.Target;
 public @interface Parameter
 {
     /**
+     * name of the bean property used to get/set the field: by default, field name is used.
+     * @return the name of the bean property
+     */
+    String name() default "";
+
+    /**
      * alias supported to get parameter value.
      * @return the alias
      */

Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
Sat May  3 15:20:29 2014
@@ -62,7 +62,7 @@ public class FirstMojo
      * @since 0.1
      * @deprecated As of 0.2
      */
-    @Parameter( alias = "alias" )
+    @Parameter( name = "namedParam", alias = "alias" )
     private String aliasedParam;
 
     @Component( role = MavenProjectHelper.class, hint = "test" )

Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
(original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
Sat May  3 15:20:29 2014
@@ -79,8 +79,8 @@ assert mojo.requirements.requirement[0].
 
 assert mojo.parameters.parameter.size() == 8
 
-parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam" }[0]
-assert parameter.name.text() == 'aliasedParam'
+parameter = mojo.parameters.parameter.findAll{ it.name.text() == "namedParam" }[0]
+assert parameter.name.text() == 'namedParam'
 assert parameter.alias.text() == 'alias'
 assert parameter.type.text() == 'java.lang.String'
 assert parameter.deprecated.text() == 'As of 0.2'

Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
Sat May  3 15:20:29 2014
@@ -58,7 +58,7 @@ public class FirstMojo
     private File touchFile;
 
     /**
-     * @parameter alias="alias"
+     * @parameter name="namedParam" alias="alias"
      * @deprecated As of 0.2
      * @since 0.1
      */

Modified: maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/verify.groovy?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/verify.groovy (original)
+++ maven/plugin-tools/trunk/maven-plugin-plugin/src/it/java-basic/verify.groovy Sat May 
3 15:20:29 2014
@@ -79,8 +79,8 @@ assert mojo.requirements.requirement[0].
 
 assert mojo.parameters.parameter.size() == 8
 
-parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam" }[0]
-assert parameter.name.text() == 'aliasedParam'
+parameter = mojo.parameters.parameter.findAll{ it.name.text() == "namedParam" }[0]
+assert parameter.name.text() == 'namedParam'
 assert parameter.alias.text() == 'alias'
 assert parameter.type.text() == 'java.lang.String'
 assert parameter.deprecated.text() == 'As of 0.2'

Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
Sat May  3 15:20:29 2014
@@ -544,7 +544,10 @@ public class JavaAnnotationsMojoDescript
             {
                 org.apache.maven.plugin.descriptor.Parameter parameter =
                     new org.apache.maven.plugin.descriptor.Parameter();
-                parameter.setName( parameterAnnotationContent.getFieldName() );
+                String name =
+                    StringUtils.isEmpty( parameterAnnotationContent.name() ) ? parameterAnnotationContent.getFieldName()
+                                    : parameterAnnotationContent.name();
+                parameter.setName( name );
                 parameter.setAlias( parameterAnnotationContent.alias() );
                 parameter.setDefaultValue( parameterAnnotationContent.defaultValue() );
                 parameter.setDeprecated( parameterAnnotationContent.getDeprecated() );

Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java
Sat May  3 15:20:29 2014
@@ -20,6 +20,7 @@ package org.apache.maven.tools.plugin.an
  */
 
 import org.apache.maven.plugins.annotations.Parameter;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.lang.annotation.Annotation;
 
@@ -32,6 +33,8 @@ public class ParameterAnnotationContent
     implements Parameter
 {
 
+    private String name;
+
     private String alias;
 
     private String property;
@@ -61,6 +64,16 @@ public class ParameterAnnotationContent
         this.readonly = readonly;
     }
 
+    public String name()
+    {
+        return name;
+    }
+
+    public void name( String name )
+    {
+        this.name = name;
+    }
+
     public String alias()
     {
         return alias;
@@ -132,7 +145,8 @@ public class ParameterAnnotationContent
         final StringBuilder sb = new StringBuilder();
         sb.append( super.toString() );
         sb.append( "ParameterAnnotationContent" );
-        sb.append( "{alias='" ).append( alias ).append( '\'' );
+        sb.append( "{name='" ).append( name ).append( '\'' );
+        sb.append( ", alias='" ).append( alias ).append( '\'' );
         sb.append( ", property='" ).append( property ).append( '\'' );
         sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
         sb.append( ", required=" ).append( required );

Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
Sat May  3 15:20:29 2014
@@ -283,6 +283,7 @@ public class DefaultMojoAnnotationsScann
                 {
                     populateAnnotationContent( parameterAnnotationContent, mojoFieldVisitor.getMojoAnnotationVisitor()
);
                 }
+
                 mojoAnnotatedClass.getParameters().put( parameterAnnotationContent.getFieldName(),
                                                         parameterAnnotationContent );
             }

Modified: maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/site/apt/index.apt?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/site/apt/index.apt (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-annotations/src/site/apt/index.apt Sat May
 3 15:20:29 2014
@@ -78,7 +78,8 @@ public class MyMojo
      * @since <since-text>
      * @deprecated <deprecated-text>
      */
-    @Parameter( alias = "myAlias",
+    @Parameter( name = "parameter",
+                alias = "myAlias",
                 property = "a.property",
                 defaultValue = "an expression, possibly with ${variables}",
                 readonly = <false|true>,

Modified: maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoAnnotation.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoAnnotation.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoAnnotation.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoAnnotation.java
Sat May  3 15:20:29 2014
@@ -272,6 +272,15 @@ public interface JavaMojoAnnotation
     String PARAMETER = "parameter";
 
     /**
+     * This defines the name of the bean property used to get/set the field: by default,
field name is used.
+     * <br/>
+     * Refer to <code>&#64;parameter name="..."</code>.
+     * <br/>
+     * <b>Note</b>: Should be defined in a Mojo Field.
+     */
+    String PARAMETER_NAME = "name";
+
+    /**
      * This defines an alias which can be used to configure a parameter. This is primarily
useful to improve
      * user-friendliness.
      * <br/>

Modified: maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
Sat May  3 15:20:29 2014
@@ -562,6 +562,13 @@ public class JavaMojoDescriptorExtractor
 
                 pd.setEditable( field.getTagByName( JavaMojoAnnotation.READONLY ) == null
);
 
+                String name = parameter.getNamedParameter( JavaMojoAnnotation.PARAMETER_NAME
);
+
+                if ( !StringUtils.isEmpty( name ) )
+                {
+                    pd.setName( name );
+                }
+
                 String alias = parameter.getNamedParameter( JavaMojoAnnotation.PARAMETER_ALIAS
);
 
                 if ( !StringUtils.isEmpty( alias ) )

Modified: maven/plugin-tools/trunk/maven-plugin-tools-java/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-java/src/site/apt/index.apt?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-java/src/site/apt/index.apt (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-java/src/site/apt/index.apt Sat May  3 15:20:29
2014
@@ -67,7 +67,7 @@ public class MyMojo
     extends AbstractMojo
 {
     /**
-     * @parameter alias="myAlias" implementation="" property="aProperty" default-value="${anExpression}"
+     * @parameter name="parameter" alias="myAlias" implementation="" property="aProperty"
default-value="${anExpression}"
      * @readonly
      * @required
      * @since <since-text>

Modified: maven/plugin-tools/trunk/maven-plugin-tools-javadoc/src/main/java/org/apache/maven/tools/plugin/javadoc/MojoParameterFieldTaglet.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-javadoc/src/main/java/org/apache/maven/tools/plugin/javadoc/MojoParameterFieldTaglet.java?rev=1592217&r1=1592216&r2=1592217&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-javadoc/src/main/java/org/apache/maven/tools/plugin/javadoc/MojoParameterFieldTaglet.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-javadoc/src/main/java/org/apache/maven/tools/plugin/javadoc/MojoParameterFieldTaglet.java
Sat May  3 15:20:29 2014
@@ -35,7 +35,7 @@ import com.sun.tools.doclets.Taglet;
  *   &#x2f;&#x2a;&#x2a;
  *   &#x20;&#x2a; Dummy parameter.
  *   &#x20;&#x2a;
- *   &#x20;&#x2a; &#64;parameter &lt;alias="..."&gt; &lt;default-value="..."&gt;
&lt;expression="..."&gt;
+ *   &#x20;&#x2a; &#64;parameter &lt;name="..."&gt; &lt;alias="..."&gt;
&lt;default-value="..."&gt; &lt;expression="..."&gt;
  *   &#x20;&#x2a; &lt;implementation="..."&gt; &lt;property="..."&gt;
  *   &#x20;&#x2a; ...
  *   &#x20;&#x2a;&#x2f;
@@ -59,6 +59,7 @@ public class MojoParameterFieldTaglet
     private static final String NAME = JavaMojoAnnotation.PARAMETER;
 
     private static final String[] PARAMETERS_NAME = {
+        JavaMojoAnnotation.PARAMETER_NAME,
         JavaMojoAnnotation.PARAMETER_ALIAS,
         JavaMojoAnnotation.PARAMETER_DEFAULT_VALUE,
         JavaMojoAnnotation.PARAMETER_EXPRESSION,



Mime
View raw message