revert back phase change help generation with doclet must continue to work
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/branches/MPLUGIN-189@1333850 13f79535-47bb-0310-9956-ffa450edef68master
parent
ddebc219e5
commit
28a6f54643
|
|
@ -42,7 +42,7 @@ public @interface Mojo
|
||||||
|
|
||||||
String requiresDependencyResolution() default "runtime";
|
String requiresDependencyResolution() default "runtime";
|
||||||
|
|
||||||
String requiresDependencyCollection() default "runtime";
|
String requiresDependencyCollection() default "";
|
||||||
|
|
||||||
String instantiationStrategy() default "per-lookup";
|
String instantiationStrategy() default "per-lookup";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
invoker.goals.2 = org.apache.maven.its.plugin:help:1.0:help
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ public class FirstMojo
|
||||||
extends AbstractMojo
|
extends AbstractMojo
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project directory.
|
||||||
|
*/
|
||||||
@Parameter( defaultValue = "${basedir}", readonly = true )
|
@Parameter( defaultValue = "${basedir}", readonly = true )
|
||||||
private File basedir;
|
private File basedir;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,29 +40,35 @@ assert mojo.requirements.requirement[0].'field-name'.text() == 'projectHelper'
|
||||||
|
|
||||||
assert mojo.parameters.parameter.size() == 3
|
assert mojo.parameters.parameter.size() == 3
|
||||||
|
|
||||||
assert mojo.parameters.parameter[0].name.text() == 'aliasedParam'
|
def parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam"}[0]
|
||||||
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 parameter.name.text() == 'aliasedParam'
|
||||||
assert mojo.parameters.parameter[1].alias.isEmpty()
|
assert parameter.alias.text() == 'alias'
|
||||||
assert mojo.parameters.parameter[1].type.text() == 'java.io.File'
|
assert parameter.type.text() == 'java.lang.String'
|
||||||
assert mojo.parameters.parameter[1].deprecated.isEmpty()
|
assert parameter.deprecated.text() == 'As of 0.2'
|
||||||
assert mojo.parameters.parameter[1].required.text() == 'false'
|
assert parameter.required.text() == 'false'
|
||||||
assert mojo.parameters.parameter[1].editable.text() == 'false'
|
assert parameter.editable.text() == 'true'
|
||||||
assert mojo.parameters.parameter[1].description.text() == 'Project directory.'
|
assert parameter.description.text() == ''
|
||||||
|
|
||||||
assert mojo.parameters.parameter[2].name.text() == 'touchFile'
|
parameter = mojo.parameters.parameter.findAll{ it.name.text() == "touchFile"}[0]
|
||||||
assert mojo.parameters.parameter[2].alias.isEmpty()
|
|
||||||
assert mojo.parameters.parameter[2].type.text() == 'java.io.File'
|
assert parameter.name.text() == 'touchFile'
|
||||||
assert mojo.parameters.parameter[2].deprecated.isEmpty()
|
assert parameter.alias.isEmpty()
|
||||||
assert mojo.parameters.parameter[2].required.text() == 'true'
|
assert parameter.type.text() == 'java.io.File'
|
||||||
assert mojo.parameters.parameter[2].editable.text() == 'true'
|
assert parameter.deprecated.isEmpty()
|
||||||
assert mojo.parameters.parameter[2].description.text() == ''
|
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]
|
mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "second"}[0]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import java.io.File;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @goal descriptor
|
* @goal descriptor
|
||||||
* @phase process-classes
|
* @phase generate-resources
|
||||||
* @requiresDependencyResolution runtime
|
* @requiresDependencyResolution runtime
|
||||||
*/
|
*/
|
||||||
public class DescriptorGeneratorMojo
|
public class DescriptorGeneratorMojo
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @since 2.4
|
* @since 2.4
|
||||||
* @goal helpmojo
|
* @goal helpmojo
|
||||||
* @phase process-classes
|
* @phase generate-sources
|
||||||
*/
|
*/
|
||||||
public class HelpGeneratorMojo
|
public class HelpGeneratorMojo
|
||||||
extends AbstractGeneratorMojo
|
extends AbstractGeneratorMojo
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.apache.maven.tools.plugin.annotations;
|
||||||
import com.thoughtworks.qdox.JavaDocBuilder;
|
import com.thoughtworks.qdox.JavaDocBuilder;
|
||||||
import com.thoughtworks.qdox.model.DocletTag;
|
import com.thoughtworks.qdox.model.DocletTag;
|
||||||
import com.thoughtworks.qdox.model.JavaClass;
|
import com.thoughtworks.qdox.model.JavaClass;
|
||||||
|
import com.thoughtworks.qdox.model.JavaField;
|
||||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||||
import org.apache.maven.plugin.descriptor.DuplicateParameterException;
|
import org.apache.maven.plugin.descriptor.DuplicateParameterException;
|
||||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||||
|
|
@ -49,6 +50,7 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
|
|
@ -124,6 +126,48 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
||||||
{
|
{
|
||||||
entry.getValue().getMojo().setDeprecated( deprecated.getValue() );
|
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 JavaAnnotationsMojoDescriptorExtractor
|
||||||
return tag;
|
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 )
|
protected Map<String, JavaClass> discoverClasses( final PluginToolsRequest request )
|
||||||
{
|
{
|
||||||
JavaDocBuilder builder = new JavaDocBuilder();
|
JavaDocBuilder builder = new JavaDocBuilder();
|
||||||
|
|
@ -208,6 +287,12 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
||||||
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>( mojoAnnotatedClasses.size() );
|
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>( mojoAnnotatedClasses.size() );
|
||||||
for ( MojoAnnotatedClass mojoAnnotatedClass : mojoAnnotatedClasses.values() )
|
for ( MojoAnnotatedClass mojoAnnotatedClass : mojoAnnotatedClasses.values() )
|
||||||
{
|
{
|
||||||
|
// no mojo so skip it
|
||||||
|
if ( mojoAnnotatedClass.getMojo() == null )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ExtendedMojoDescriptor mojoDescriptor = new ExtendedMojoDescriptor();
|
ExtendedMojoDescriptor mojoDescriptor = new ExtendedMojoDescriptor();
|
||||||
|
|
||||||
//mojoDescriptor.setRole( mojoAnnotatedClass.getClassName() );
|
//mojoDescriptor.setRole( mojoAnnotatedClass.getClassName() );
|
||||||
|
|
@ -223,6 +308,8 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
||||||
|
|
||||||
mojoDescriptor.setAggregator( mojo.aggregator() );
|
mojoDescriptor.setAggregator( mojo.aggregator() );
|
||||||
mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution() );
|
mojoDescriptor.setDependencyResolutionRequired( mojo.requiresDependencyResolution() );
|
||||||
|
mojoDescriptor.setDependencyCollectionRequired( mojo.requiresDependencyCollection() );
|
||||||
|
|
||||||
mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() );
|
mojoDescriptor.setDirectInvocationOnly( mojo.requiresDirectInvocation() );
|
||||||
mojoDescriptor.setDeprecated( mojo.getDeprecated() );
|
mojoDescriptor.setDeprecated( mojo.getDeprecated() );
|
||||||
mojoDescriptor.setThreadSafe( mojo.threadSafe() );
|
mojoDescriptor.setThreadSafe( mojo.threadSafe() );
|
||||||
|
|
@ -245,7 +332,7 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
||||||
|
|
||||||
mojoDescriptor.setPhase( mojo.defaultPhase().id() );
|
mojoDescriptor.setPhase( mojo.defaultPhase().id() );
|
||||||
|
|
||||||
for ( ParameterAnnotationContent parameterAnnotationContent : mojoAnnotatedClass.getParameters() )
|
for ( ParameterAnnotationContent parameterAnnotationContent : mojoAnnotatedClass.getParameters().values() )
|
||||||
{
|
{
|
||||||
org.apache.maven.plugin.descriptor.Parameter parameter =
|
org.apache.maven.plugin.descriptor.Parameter parameter =
|
||||||
new org.apache.maven.plugin.descriptor.Parameter();
|
new org.apache.maven.plugin.descriptor.Parameter();
|
||||||
|
|
@ -256,10 +343,13 @@ public class JavaAnnotationsMojoDescriptorExtractor
|
||||||
parameter.setDescription( parameterAnnotationContent.getDescription() );
|
parameter.setDescription( parameterAnnotationContent.getDescription() );
|
||||||
parameter.setEditable( !parameterAnnotationContent.readonly() );
|
parameter.setEditable( !parameterAnnotationContent.readonly() );
|
||||||
parameter.setExpression( parameterAnnotationContent.expression() );
|
parameter.setExpression( parameterAnnotationContent.expression() );
|
||||||
|
parameter.setType( parameterAnnotationContent.getClassName() );
|
||||||
|
parameter.setRequired( parameterAnnotationContent.required() );
|
||||||
|
|
||||||
mojoDescriptor.addParameter( parameter );
|
mojoDescriptor.addParameter( parameter );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ComponentAnnotationContent componentAnnotationContent : mojoAnnotatedClass.getComponents() )
|
for ( ComponentAnnotationContent componentAnnotationContent : mojoAnnotatedClass.getComponents().values() )
|
||||||
{
|
{
|
||||||
org.apache.maven.plugin.descriptor.Parameter parameter =
|
org.apache.maven.plugin.descriptor.Parameter parameter =
|
||||||
new org.apache.maven.plugin.descriptor.Parameter();
|
new org.apache.maven.plugin.descriptor.Parameter();
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class MojoAnnotationContent
|
||||||
|
|
||||||
private String requiresDependencyResolution = "runtime";
|
private String requiresDependencyResolution = "runtime";
|
||||||
|
|
||||||
private String requiresDependencyCollection = "runtime";
|
private String requiresDependencyCollection;
|
||||||
|
|
||||||
private String instantiationStrategy = "per-lookup";
|
private String instantiationStrategy = "per-lookup";
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class MojoAnnotationContent
|
||||||
|
|
||||||
public String requiresDependencyCollection()
|
public String requiresDependencyCollection()
|
||||||
{
|
{
|
||||||
return requiresDependencyCollection;
|
return requiresDependencyCollection == null ? "" : requiresDependencyCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requiresDependencyCollection( String requiresDependencyCollection )
|
public void requiresDependencyCollection( String requiresDependencyCollection )
|
||||||
|
|
|
||||||
|
|
@ -41,15 +41,18 @@ public class ParameterAnnotationContent
|
||||||
|
|
||||||
private boolean readonly = false;
|
private boolean readonly = false;
|
||||||
|
|
||||||
public ParameterAnnotationContent( String fieldName )
|
private String className;
|
||||||
|
|
||||||
|
public ParameterAnnotationContent( String fieldName, String className )
|
||||||
{
|
{
|
||||||
super( fieldName );
|
super( fieldName );
|
||||||
|
this.className = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParameterAnnotationContent( String fieldName, String alias, String expression, String defaultValue,
|
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.alias = alias;
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
|
|
@ -112,6 +115,16 @@ public class ParameterAnnotationContent
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClassName()
|
||||||
|
{
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassName( String className )
|
||||||
|
{
|
||||||
|
this.className = className;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ public class DefaultMojoAnnotationsScanner
|
||||||
for ( MojoFieldVisitor mojoFieldVisitor : mojoFieldVisitors )
|
for ( MojoFieldVisitor mojoFieldVisitor : mojoFieldVisitors )
|
||||||
{
|
{
|
||||||
ParameterAnnotationContent parameterAnnotationContent =
|
ParameterAnnotationContent parameterAnnotationContent =
|
||||||
new ParameterAnnotationContent( mojoFieldVisitor.getFieldName() );
|
new ParameterAnnotationContent( mojoFieldVisitor.getFieldName(), mojoFieldVisitor.getClassName() );
|
||||||
if ( mojoFieldVisitor.getMojoAnnotationVisitor() != null )
|
if ( mojoFieldVisitor.getMojoAnnotationVisitor() != null )
|
||||||
{
|
{
|
||||||
for ( Map.Entry<String, Object> entry : mojoFieldVisitor.getMojoAnnotationVisitor().getAnnotationValues().entrySet() )
|
for ( Map.Entry<String, Object> entry : mojoFieldVisitor.getMojoAnnotationVisitor().getAnnotationValues().entrySet() )
|
||||||
|
|
@ -183,7 +183,8 @@ public class DefaultMojoAnnotationsScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
mojoClassVisitor.getMojoAnnotatedClass().getParameters().add( parameterAnnotationContent );
|
mojoClassVisitor.getMojoAnnotatedClass().getParameters().put( parameterAnnotationContent.getFieldName(),
|
||||||
|
parameterAnnotationContent );
|
||||||
}
|
}
|
||||||
|
|
||||||
mojoFieldVisitors = mojoClassVisitor.findFieldWithAnnotationClass( Component.class.getName() );
|
mojoFieldVisitors = mojoClassVisitor.findFieldWithAnnotationClass( Component.class.getName() );
|
||||||
|
|
@ -202,7 +203,8 @@ public class DefaultMojoAnnotationsScanner
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
mojoClassVisitor.getMojoAnnotatedClass().getComponents().add( componentAnnotationContent );
|
mojoClassVisitor.getMojoAnnotatedClass().getComponents().put( componentAnnotationContent.getFieldName(),
|
||||||
|
componentAnnotationContent );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ import org.apache.maven.tools.plugin.annotations.datamodel.ExecuteAnnotationCont
|
||||||
import org.apache.maven.tools.plugin.annotations.datamodel.MojoAnnotationContent;
|
import org.apache.maven.tools.plugin.annotations.datamodel.MojoAnnotationContent;
|
||||||
import org.apache.maven.tools.plugin.annotations.datamodel.ParameterAnnotationContent;
|
import org.apache.maven.tools.plugin.annotations.datamodel.ParameterAnnotationContent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
|
|
@ -40,9 +40,15 @@ public class MojoAnnotatedClass
|
||||||
|
|
||||||
private ExecuteAnnotationContent execute;
|
private ExecuteAnnotationContent execute;
|
||||||
|
|
||||||
private List<ParameterAnnotationContent> parameters;
|
/**
|
||||||
|
* key is field name
|
||||||
|
*/
|
||||||
|
private Map<String, ParameterAnnotationContent> parameters;
|
||||||
|
|
||||||
private List<ComponentAnnotationContent> components;
|
/**
|
||||||
|
* key is field name
|
||||||
|
*/
|
||||||
|
private Map<String, ComponentAnnotationContent> components;
|
||||||
|
|
||||||
public MojoAnnotatedClass()
|
public MojoAnnotatedClass()
|
||||||
{
|
{
|
||||||
|
|
@ -82,31 +88,31 @@ public class MojoAnnotatedClass
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ParameterAnnotationContent> getParameters()
|
public Map<String, ParameterAnnotationContent> getParameters()
|
||||||
{
|
{
|
||||||
if ( this.parameters == null )
|
if ( this.parameters == null )
|
||||||
{
|
{
|
||||||
this.parameters = new ArrayList<ParameterAnnotationContent>();
|
this.parameters = new HashMap<String, ParameterAnnotationContent>();
|
||||||
}
|
}
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojoAnnotatedClass setParameters( List<ParameterAnnotationContent> parameters )
|
public MojoAnnotatedClass setParameters( Map<String, ParameterAnnotationContent> parameters )
|
||||||
{
|
{
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ComponentAnnotationContent> getComponents()
|
public Map<String, ComponentAnnotationContent> getComponents()
|
||||||
{
|
{
|
||||||
if ( this.components == null )
|
if ( this.components == null )
|
||||||
{
|
{
|
||||||
this.components = new ArrayList<ComponentAnnotationContent>();
|
this.components = new HashMap<String, ComponentAnnotationContent>();
|
||||||
}
|
}
|
||||||
return components;
|
return components;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojoAnnotatedClass setComponents( List<ComponentAnnotationContent> components )
|
public MojoAnnotatedClass setComponents( Map<String, ComponentAnnotationContent> components )
|
||||||
{
|
{
|
||||||
this.components = components;
|
this.components = components;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,8 @@ public class MojoClassVisitor
|
||||||
|
|
||||||
public FieldVisitor visitField( int access, String name, String desc, String signature, Object value )
|
public FieldVisitor visitField( int access, String name, String desc, String signature, Object value )
|
||||||
{
|
{
|
||||||
// Type.getType( desc ).getClassName()
|
|
||||||
logger.debug( "MojoClassVisitor#visitField" );
|
logger.debug( "MojoClassVisitor#visitField" );
|
||||||
MojoFieldVisitor mojoFieldVisitor = new MojoFieldVisitor( logger, name );
|
MojoFieldVisitor mojoFieldVisitor = new MojoFieldVisitor( logger, name, Type.getType( desc ).getClassName() );
|
||||||
fieldVisitors.add( mojoFieldVisitor );
|
fieldVisitors.add( mojoFieldVisitor );
|
||||||
return mojoFieldVisitor;
|
return mojoFieldVisitor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,13 @@ public class MojoFieldVisitor
|
||||||
|
|
||||||
private MojoAnnotationVisitor mojoAnnotationVisitor;
|
private MojoAnnotationVisitor mojoAnnotationVisitor;
|
||||||
|
|
||||||
MojoFieldVisitor( Logger logger, String fieldName )
|
private String className;
|
||||||
|
|
||||||
|
MojoFieldVisitor( Logger logger, String fieldName, String className )
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.className = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojoAnnotationVisitor getMojoAnnotationVisitor()
|
public MojoAnnotationVisitor getMojoAnnotationVisitor()
|
||||||
|
|
@ -75,4 +78,14 @@ public class MojoFieldVisitor
|
||||||
{
|
{
|
||||||
logger.debug( "MojoFieldVisitor#visitEnd" );
|
logger.debug( "MojoFieldVisitor#visitEnd" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClassName()
|
||||||
|
{
|
||||||
|
return className;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassName( String className )
|
||||||
|
{
|
||||||
|
this.className = className;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import org.apache.maven.plugins.annotations.Parameter;
|
||||||
public class FooMojo
|
public class FooMojo
|
||||||
extends AbstractMojo
|
extends AbstractMojo
|
||||||
{
|
{
|
||||||
@Parameter( expression = "${thebar}" )
|
@Parameter( expression = "${thebar}", required = true)
|
||||||
private String bar;
|
private String bar;
|
||||||
|
|
||||||
@Parameter( expression = "${thebeer}" )
|
@Parameter( expression = "${thebeer}" )
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ import org.fest.assertions.Assertions;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -75,12 +75,12 @@ public class TestAnnotationsReader
|
||||||
assertEquals( "my-lifecycle", execute.lifecycle() );
|
assertEquals( "my-lifecycle", execute.lifecycle() );
|
||||||
assertEquals( LifecyclePhase.PACKAGE, execute.phase() );
|
assertEquals( LifecyclePhase.PACKAGE, execute.phase() );
|
||||||
|
|
||||||
List<ComponentAnnotationContent> components = mojoAnnotatedClass.getComponents();
|
Collection<ComponentAnnotationContent> components = mojoAnnotatedClass.getComponents().values();
|
||||||
Assertions.assertThat( components ).isNotNull().isNotEmpty().hasSize( 2 );
|
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(
|
Assertions.assertThat( parameters ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
|
||||||
new ParameterAnnotationContent( "bar", null, "${thebar}", null, false, false ),
|
new ParameterAnnotationContent( "bar", null, "${thebar}", null, true, false, String.class.getName() ),
|
||||||
new ParameterAnnotationContent( "beer", null, "${thebeer}", null, false, false ) );
|
new ParameterAnnotationContent( "beer", null, "${thebeer}", null, false, false, String.class.getName() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue