You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/05/04 12:05:17 UTC
svn commit: r1333850 - in /maven/plugin-tools/branches/MPLUGIN-189:
maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/
maven-plugin-plugin/src/it/help-basic/
maven-plugin-plugin/src/it/java-basic-annotations/ maven-plugin-plug...
Author: olamy
Date: Fri May 4 10:05:16 2012
New Revision: 1333850
URL: http://svn.apache.org/viewvc?rev=1333850&view=rev
Log:
revert back phase change help generation with doclet must continue to work
Modified:
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Mojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/MojoAnnotationContent.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoClassVisitor.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoFieldVisitor.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java
maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Mojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Mojo.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Mojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Mojo.java Fri May 4 10:05:16 2012
@@ -42,7 +42,7 @@ public @interface Mojo
String requiresDependencyResolution() default "runtime";
- String requiresDependencyCollection() default "runtime";
+ String requiresDependencyCollection() default "";
String instantiationStrategy() default "per-lookup";
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/help-basic/invoker.properties Fri May 4 10:05:16 2012
@@ -1,2 +1,2 @@
-invoker.goals.1 = install
+invoker.goals.1 = install -DskipTests
invoker.goals.2 = org.apache.maven.its.plugin:help:1.0:help
Modified: maven/plugin-tools/branches/MPLUGIN-189/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/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java Fri May 4 10:05:16 2012
@@ -41,6 +41,9 @@ public class FirstMojo
extends AbstractMojo
{
+ /**
+ * Project directory.
+ */
@Parameter( defaultValue = "${basedir}", readonly = true )
private File basedir;
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy Fri May 4 10:05:16 2012
@@ -40,29 +40,35 @@ assert mojo.requirements.requirement[0].
assert mojo.parameters.parameter.size() == 3
-assert mojo.parameters.parameter[0].name.text() == 'aliasedParam'
-assert mojo.parameters.parameter[0].alias.text() == 'alias'
-assert mojo.parameters.parameter[0].type.text() == 'java.lang.String'
-assert mojo.parameters.parameter[0].deprecated.text() == 'As of 0.2'
-assert mojo.parameters.parameter[0].required.text() == 'false'
-assert mojo.parameters.parameter[0].editable.text() == 'true'
-assert mojo.parameters.parameter[0].description.text() == ''
-
-assert mojo.parameters.parameter[1].name.text() == 'basedir'
-assert mojo.parameters.parameter[1].alias.isEmpty()
-assert mojo.parameters.parameter[1].type.text() == 'java.io.File'
-assert mojo.parameters.parameter[1].deprecated.isEmpty()
-assert mojo.parameters.parameter[1].required.text() == 'false'
-assert mojo.parameters.parameter[1].editable.text() == 'false'
-assert mojo.parameters.parameter[1].description.text() == 'Project directory.'
-
-assert mojo.parameters.parameter[2].name.text() == 'touchFile'
-assert mojo.parameters.parameter[2].alias.isEmpty()
-assert mojo.parameters.parameter[2].type.text() == 'java.io.File'
-assert mojo.parameters.parameter[2].deprecated.isEmpty()
-assert mojo.parameters.parameter[2].required.text() == 'true'
-assert mojo.parameters.parameter[2].editable.text() == 'true'
-assert mojo.parameters.parameter[2].description.text() == ''
+def parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam"}[0]
+
+assert parameter.name.text() == 'aliasedParam'
+assert parameter.alias.text() == 'alias'
+assert parameter.type.text() == 'java.lang.String'
+assert parameter.deprecated.text() == 'As of 0.2'
+assert parameter.required.text() == 'false'
+assert parameter.editable.text() == 'true'
+assert parameter.description.text() == ''
+
+parameter = mojo.parameters.parameter.findAll{ it.name.text() == "touchFile"}[0]
+
+assert parameter.name.text() == 'touchFile'
+assert parameter.alias.isEmpty()
+assert parameter.type.text() == 'java.io.File'
+assert parameter.deprecated.isEmpty()
+assert parameter.required.text() == 'true'
+assert parameter.editable.text() == 'true'
+assert parameter.description.text() == ''
+
+parameter = mojo.parameters.parameter.findAll{ it.name.text() == "basedir"}[0]
+
+assert parameter.name.text() == 'basedir'
+assert parameter.alias.isEmpty()
+assert parameter.type.text() == 'java.io.File'
+assert parameter.deprecated.isEmpty()
+assert parameter.required.text() == 'false'
+assert parameter.editable.text() == 'false'
+assert parameter.description.text() == 'Project directory.'
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0]
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java Fri May 4 10:05:16 2012
@@ -34,7 +34,7 @@ import java.io.File;
* @version $Id$
* @since 2.0
* @goal descriptor
- * @phase process-classes
+ * @phase generate-resources
* @requiresDependencyResolution runtime
*/
public class DescriptorGeneratorMojo
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java Fri May 4 10:05:16 2012
@@ -32,7 +32,7 @@ import org.apache.maven.tools.plugin.gen
* @version $Id$
* @since 2.4
* @goal helpmojo
- * @phase process-classes
+ * @phase generate-sources
*/
public class HelpGeneratorMojo
extends AbstractGeneratorMojo
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/JavaAnnotationsMojoDescriptorExtractor.java Fri May 4 10:05:16 2012
@@ -21,6 +21,7 @@ package org.apache.maven.tools.plugin.an
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.descriptor.DuplicateParameterException;
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
@@ -49,6 +50,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
/**
* @author Olivier Lamy
@@ -124,6 +126,48 @@ public class JavaAnnotationsMojoDescript
{
entry.getValue().getMojo().setDeprecated( deprecated.getValue() );
}
+
+ Map<String, JavaField> fieldsMap = extractFieldParameterTags( javaClass );
+ for ( Map.Entry<String, ParameterAnnotationContent> parameter : entry.getValue().getParameters().entrySet() )
+ {
+ JavaField javaField = fieldsMap.get( parameter.getKey() );
+ if ( javaField != null )
+ {
+ ParameterAnnotationContent parameterAnnotationContent = parameter.getValue();
+ deprecated = javaField.getTagByName( "deprecated" );
+ if ( deprecated != null )
+ {
+ parameterAnnotationContent.setDeprecated( deprecated.getValue() );
+ }
+ since = javaField.getTagByName( "since" );
+ if ( since != null )
+ {
+ parameterAnnotationContent.setSince( since.getValue() );
+ }
+ parameterAnnotationContent.setDescription( javaField.getComment() );
+ }
+ }
+
+ for ( Map.Entry<String, ComponentAnnotationContent> component : entry.getValue().getComponents().entrySet() )
+ {
+ JavaField javaField = fieldsMap.get( component.getKey() );
+ if ( javaField != null )
+ {
+ ComponentAnnotationContent componentAnnotationContent = component.getValue();
+ deprecated = javaField.getTagByName( "deprecated" );
+ if ( deprecated != null )
+ {
+ componentAnnotationContent.setDeprecated( deprecated.getValue() );
+ }
+ since = javaField.getTagByName( "since" );
+ if ( since != null )
+ {
+ componentAnnotationContent.setSince( since.getValue() );
+ }
+ componentAnnotationContent.setDescription( javaField.getComment() );
+ }
+ }
+
}
}
@@ -151,6 +195,41 @@ public class JavaAnnotationsMojoDescript
return tag;
}
+ /**
+ * extract fields that are either parameters or components.
+ *
+ * @param javaClass not null
+ * @return map with Mojo parameters names as keys
+ */
+ private Map<String, JavaField> extractFieldParameterTags( JavaClass javaClass )
+ {
+ Map<String, JavaField> rawParams;
+
+ // we have to add the parent fields first, so that they will be overwritten by the local fields if
+ // that actually happens...
+ JavaClass superClass = javaClass.getSuperJavaClass();
+
+ if ( superClass != null )
+ {
+ rawParams = extractFieldParameterTags( superClass );
+ }
+ else
+ {
+ rawParams = new TreeMap<String, JavaField>();
+ }
+
+ JavaField[] classFields = javaClass.getFields();
+
+ if ( classFields != null )
+ {
+ for ( JavaField field : classFields )
+ {
+ rawParams.put( field.getName(), field );
+ }
+ }
+ return rawParams;
+ }
+
protected Map<String, JavaClass> discoverClasses( final PluginToolsRequest request )
{
JavaDocBuilder builder = new JavaDocBuilder();
@@ -208,6 +287,12 @@ public class JavaAnnotationsMojoDescript
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>( mojoAnnotatedClasses.size() );
for ( MojoAnnotatedClass mojoAnnotatedClass : mojoAnnotatedClasses.values() )
{
+ // no mojo so skip it
+ if ( mojoAnnotatedClass.getMojo() == null )
+ {
+ continue;
+ }
+
ExtendedMojoDescriptor mojoDescriptor = new ExtendedMojoDescriptor();
//mojoDescriptor.setRole( mojoAnnotatedClass.getClassName() );
@@ -223,6 +308,8 @@ public class JavaAnnotationsMojoDescript
mojoDescriptor.setAggregator( mojo.aggregator() );
mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution() );
+ mojoDescriptor.setDependencyCollectionRequired( mojo.requiresDependencyCollection() );
+
mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() );
mojoDescriptor.setDeprecated( mojo.getDeprecated() );
mojoDescriptor.setThreadSafe( mojo.threadSafe() );
@@ -245,7 +332,7 @@ public class JavaAnnotationsMojoDescript
mojoDescriptor.setPhase( mojo.defaultPhase().id() );
- for ( ParameterAnnotationContent parameterAnnotationContent : mojoAnnotatedClass.getParameters() )
+ for ( ParameterAnnotationContent parameterAnnotationContent : mojoAnnotatedClass.getParameters().values() )
{
org.apache.maven.plugin.descriptor.Parameter parameter =
new org.apache.maven.plugin.descriptor.Parameter();
@@ -256,10 +343,13 @@ public class JavaAnnotationsMojoDescript
parameter.setDescription( parameterAnnotationContent.getDescription() );
parameter.setEditable( !parameterAnnotationContent.readonly() );
parameter.setExpression( parameterAnnotationContent.expression() );
+ parameter.setType( parameterAnnotationContent.getClassName() );
+ parameter.setRequired( parameterAnnotationContent.required() );
+
mojoDescriptor.addParameter( parameter );
}
- for ( ComponentAnnotationContent componentAnnotationContent : mojoAnnotatedClass.getComponents() )
+ for ( ComponentAnnotationContent componentAnnotationContent : mojoAnnotatedClass.getComponents().values() )
{
org.apache.maven.plugin.descriptor.Parameter parameter =
new org.apache.maven.plugin.descriptor.Parameter();
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/MojoAnnotationContent.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/MojoAnnotationContent.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/MojoAnnotationContent.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/MojoAnnotationContent.java Fri May 4 10:05:16 2012
@@ -37,7 +37,7 @@ public class MojoAnnotationContent
private String requiresDependencyResolution = "runtime";
- private String requiresDependencyCollection = "runtime";
+ private String requiresDependencyCollection;
private String instantiationStrategy = "per-lookup";
@@ -86,7 +86,7 @@ public class MojoAnnotationContent
public String requiresDependencyCollection()
{
- return requiresDependencyCollection;
+ return requiresDependencyCollection == null ? "" : requiresDependencyCollection;
}
public void requiresDependencyCollection( String requiresDependencyCollection )
Modified: maven/plugin-tools/branches/MPLUGIN-189/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/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/datamodel/ParameterAnnotationContent.java Fri May 4 10:05:16 2012
@@ -41,15 +41,18 @@ public class ParameterAnnotationContent
private boolean readonly = false;
- public ParameterAnnotationContent( String fieldName )
+ private String className;
+
+ public ParameterAnnotationContent( String fieldName, String className )
{
super( fieldName );
+ this.className = className;
}
public ParameterAnnotationContent( String fieldName, String alias, String expression, String defaultValue,
- boolean required, boolean readonly )
+ boolean required, boolean readonly, String className )
{
- this( fieldName );
+ this( fieldName, className );
this.alias = alias;
this.expression = expression;
this.defaultValue = defaultValue;
@@ -112,6 +115,16 @@ public class ParameterAnnotationContent
return null;
}
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName( String className )
+ {
+ this.className = className;
+ }
+
@Override
public String toString()
{
Modified: maven/plugin-tools/branches/MPLUGIN-189/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/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/DefaultMojoAnnotationsScanner.java Fri May 4 10:05:16 2012
@@ -173,7 +173,7 @@ public class DefaultMojoAnnotationsScann
for ( MojoFieldVisitor mojoFieldVisitor : mojoFieldVisitors )
{
ParameterAnnotationContent parameterAnnotationContent =
- new ParameterAnnotationContent( mojoFieldVisitor.getFieldName() );
+ new ParameterAnnotationContent( mojoFieldVisitor.getFieldName(), mojoFieldVisitor.getClassName() );
if ( mojoFieldVisitor.getMojoAnnotationVisitor() != null )
{
for ( Map.Entry<String, Object> entry : mojoFieldVisitor.getMojoAnnotationVisitor().getAnnotationValues().entrySet() )
@@ -183,7 +183,8 @@ public class DefaultMojoAnnotationsScann
}
}
- mojoClassVisitor.getMojoAnnotatedClass().getParameters().add( parameterAnnotationContent );
+ mojoClassVisitor.getMojoAnnotatedClass().getParameters().put( parameterAnnotationContent.getFieldName(),
+ parameterAnnotationContent );
}
mojoFieldVisitors = mojoClassVisitor.findFieldWithAnnotationClass( Component.class.getName() );
@@ -202,7 +203,8 @@ public class DefaultMojoAnnotationsScann
}
}
- mojoClassVisitor.getMojoAnnotatedClass().getComponents().add( componentAnnotationContent );
+ mojoClassVisitor.getMojoAnnotatedClass().getComponents().put( componentAnnotationContent.getFieldName(),
+ componentAnnotationContent );
}
}
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/MojoAnnotatedClass.java Fri May 4 10:05:16 2012
@@ -23,8 +23,8 @@ import org.apache.maven.tools.plugin.ann
import org.apache.maven.tools.plugin.annotations.datamodel.MojoAnnotationContent;
import org.apache.maven.tools.plugin.annotations.datamodel.ParameterAnnotationContent;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
/**
* @author Olivier Lamy
@@ -40,9 +40,15 @@ public class MojoAnnotatedClass
private ExecuteAnnotationContent execute;
- private List<ParameterAnnotationContent> parameters;
-
- private List<ComponentAnnotationContent> components;
+ /**
+ * key is field name
+ */
+ private Map<String, ParameterAnnotationContent> parameters;
+
+ /**
+ * key is field name
+ */
+ private Map<String, ComponentAnnotationContent> components;
public MojoAnnotatedClass()
{
@@ -82,31 +88,31 @@ public class MojoAnnotatedClass
return this;
}
- public List<ParameterAnnotationContent> getParameters()
+ public Map<String, ParameterAnnotationContent> getParameters()
{
if ( this.parameters == null )
{
- this.parameters = new ArrayList<ParameterAnnotationContent>();
+ this.parameters = new HashMap<String, ParameterAnnotationContent>();
}
return parameters;
}
- public MojoAnnotatedClass setParameters( List<ParameterAnnotationContent> parameters )
+ public MojoAnnotatedClass setParameters( Map<String, ParameterAnnotationContent> parameters )
{
this.parameters = parameters;
return this;
}
- public List<ComponentAnnotationContent> getComponents()
+ public Map<String, ComponentAnnotationContent> getComponents()
{
if ( this.components == null )
{
- this.components = new ArrayList<ComponentAnnotationContent>();
+ this.components = new HashMap<String, ComponentAnnotationContent>();
}
return components;
}
- public MojoAnnotatedClass setComponents( List<ComponentAnnotationContent> components )
+ public MojoAnnotatedClass setComponents( Map<String, ComponentAnnotationContent> components )
{
this.components = components;
return this;
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoClassVisitor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoClassVisitor.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoClassVisitor.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoClassVisitor.java Fri May 4 10:05:16 2012
@@ -124,9 +124,8 @@ public class MojoClassVisitor
public FieldVisitor visitField( int access, String name, String desc, String signature, Object value )
{
- // Type.getType( desc ).getClassName()
logger.debug( "MojoClassVisitor#visitField" );
- MojoFieldVisitor mojoFieldVisitor = new MojoFieldVisitor( logger, name );
+ MojoFieldVisitor mojoFieldVisitor = new MojoFieldVisitor( logger, name, Type.getType( desc ).getClassName() );
fieldVisitors.add( mojoFieldVisitor );
return mojoFieldVisitor;
}
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoFieldVisitor.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoFieldVisitor.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoFieldVisitor.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/annotations/scanner/visitors/MojoFieldVisitor.java Fri May 4 10:05:16 2012
@@ -38,10 +38,13 @@ public class MojoFieldVisitor
private MojoAnnotationVisitor mojoAnnotationVisitor;
- MojoFieldVisitor( Logger logger, String fieldName )
+ private String className;
+
+ MojoFieldVisitor( Logger logger, String fieldName, String className )
{
this.logger = logger;
this.fieldName = fieldName;
+ this.className = className;
}
public MojoAnnotationVisitor getMojoAnnotationVisitor()
@@ -75,4 +78,14 @@ public class MojoFieldVisitor
{
logger.debug( "MojoFieldVisitor#visitEnd" );
}
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName( String className )
+ {
+ this.className = className;
+ }
}
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/FooMojo.java Fri May 4 10:05:16 2012
@@ -35,7 +35,7 @@ import org.apache.maven.plugins.annotati
public class FooMojo
extends AbstractMojo
{
- @Parameter( expression = "${thebar}" )
+ @Parameter( expression = "${thebar}", required = true)
private String bar;
@Parameter( expression = "${thebeer}" )
Modified: maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java?rev=1333850&r1=1333849&r2=1333850&view=diff
==============================================================================
--- maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java (original)
+++ maven/plugin-tools/branches/MPLUGIN-189/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/annotations/TestAnnotationsReader.java Fri May 4 10:05:16 2012
@@ -32,8 +32,8 @@ import org.fest.assertions.Assertions;
import java.io.File;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
/**
@@ -75,12 +75,12 @@ public class TestAnnotationsReader
assertEquals( "my-lifecycle", execute.lifecycle() );
assertEquals( LifecyclePhase.PACKAGE, execute.phase() );
- List<ComponentAnnotationContent> components = mojoAnnotatedClass.getComponents();
+ Collection<ComponentAnnotationContent> components = mojoAnnotatedClass.getComponents().values();
Assertions.assertThat( components ).isNotNull().isNotEmpty().hasSize( 2 );
- List<ParameterAnnotationContent> parameters = mojoAnnotatedClass.getParameters();
+ Collection<ParameterAnnotationContent> parameters = mojoAnnotatedClass.getParameters().values();
Assertions.assertThat( parameters ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
- new ParameterAnnotationContent( "bar", null, "${thebar}", null, false, false ),
- new ParameterAnnotationContent( "beer", null, "${thebeer}", null, false, false ) );
+ new ParameterAnnotationContent( "bar", null, "${thebar}", null, true, false, String.class.getName() ),
+ new ParameterAnnotationContent( "beer", null, "${thebeer}", null, false, false, String.class.getName() ) );
}
}