MPLUGIN-134: Review the support of Mojo's annotations

o ordering annotations

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@685111 13f79535-47bb-0310-9956-ffa450edef68
master
Vincent Siveton 2008-08-12 10:38:09 +00:00
parent e10914b835
commit 7a4c3a9bd5
1 changed files with 74 additions and 67 deletions

View File

@ -201,20 +201,15 @@ public class JavaMojoDescriptorExtractor
mojoDescriptor.setImplementation( javaClass.getFullyQualifiedName() ); mojoDescriptor.setImplementation( javaClass.getFullyQualifiedName() );
mojoDescriptor.setDescription( javaClass.getComment() ); mojoDescriptor.setDescription( javaClass.getComment() );
// instantiationStrategy // ----------------------------------------------------------------------
DocletTag tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.INSTANTIATION_STRATEGY ); // Mojo annotations in alphabetical order
if ( tag != null ) // ----------------------------------------------------------------------
// Aggregator flag
DocletTag aggregator = findInClassHierarchy( javaClass, JavaMojoAnnotation.AGGREGATOR );
if ( aggregator != null )
{ {
mojoDescriptor.setInstantiationStrategy( tag.getValue() ); mojoDescriptor.setAggregator( true );
}
tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.MULTI_EXECUTION_STRATEGY );
if ( tag != null )
{
mojoDescriptor.setExecutionStrategy( MojoDescriptor.MULTI_PASS_EXEC_STRATEGY );
}
else
{
mojoDescriptor.setExecutionStrategy( MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY );
} }
// Configurator hint // Configurator hint
@ -224,34 +219,6 @@ public class JavaMojoDescriptorExtractor
mojoDescriptor.setComponentConfigurator( configurator.getValue() ); mojoDescriptor.setComponentConfigurator( configurator.getValue() );
} }
// Goal name
DocletTag goal = findInClassHierarchy( javaClass, JavaMojoAnnotation.GOAL );
if ( goal != null )
{
mojoDescriptor.setGoal( goal.getValue() );
}
// What version it was introduced in
DocletTag since = findInClassHierarchy( javaClass, JavaMojoAnnotation.SINCE );
if ( since != null )
{
mojoDescriptor.setSince( since.getValue() );
}
// Deprecation hint
DocletTag deprecated = javaClass.getTagByName( JavaMojoAnnotation.DEPRECATED );
if ( deprecated != null )
{
mojoDescriptor.setDeprecated( deprecated.getValue() );
}
// Phase name
DocletTag phase = findInClassHierarchy( javaClass, JavaMojoAnnotation.PHASE );
if ( phase != null )
{
mojoDescriptor.setPhase( phase.getValue() );
}
// Additional phase to execute first // Additional phase to execute first
DocletTag execute = findInClassHierarchy( javaClass, JavaMojoAnnotation.EXECUTE ); DocletTag execute = findInClassHierarchy( javaClass, JavaMojoAnnotation.EXECUTE );
if ( execute != null ) if ( execute != null )
@ -283,36 +250,55 @@ public class JavaMojoDescriptorExtractor
} }
} }
// Goal name
DocletTag goal = findInClassHierarchy( javaClass, JavaMojoAnnotation.GOAL );
if ( goal != null )
{
mojoDescriptor.setGoal( goal.getValue() );
}
// inheritByDefault flag
boolean value =
getBooleanTagValue( javaClass, JavaMojoAnnotation.INHERIT_BY_DEFAULT,
mojoDescriptor.isInheritedByDefault() );
mojoDescriptor.setInheritedByDefault( value );
// instantiationStrategy
DocletTag tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.INSTANTIATION_STRATEGY );
if ( tag != null )
{
mojoDescriptor.setInstantiationStrategy( tag.getValue() );
}
tag = findInClassHierarchy( javaClass, JavaMojoAnnotation.MULTI_EXECUTION_STRATEGY );
if ( tag != null )
{
mojoDescriptor.setExecutionStrategy( MojoDescriptor.MULTI_PASS_EXEC_STRATEGY );
}
else
{
mojoDescriptor.setExecutionStrategy( MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY );
}
// Phase name
DocletTag phase = findInClassHierarchy( javaClass, JavaMojoAnnotation.PHASE );
if ( phase != null )
{
mojoDescriptor.setPhase( phase.getValue() );
}
// Dependency resolution flag // Dependency resolution flag
DocletTag requiresDependencyResolution = DocletTag requiresDependencyResolution =
findInClassHierarchy( javaClass, JavaMojoAnnotation.REQUIRES_DEPENDENCY_RESOLUTION ); findInClassHierarchy( javaClass, JavaMojoAnnotation.REQUIRES_DEPENDENCY_RESOLUTION );
if ( requiresDependencyResolution != null ) if ( requiresDependencyResolution != null )
{ {
String value = requiresDependencyResolution.getValue(); String v = requiresDependencyResolution.getValue();
if ( value == null || value.length() == 0 ) if ( StringUtils.isEmpty( v ) )
{ {
value = "runtime"; v = "runtime";
} }
mojoDescriptor.setDependencyResolutionRequired( value ); mojoDescriptor.setDependencyResolutionRequired( v );
}
// Project flag
boolean value =
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_PROJECT, mojoDescriptor.isProjectRequired() );
mojoDescriptor.setProjectRequired( value );
// requiresReports flag
value =
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_REPORTS, mojoDescriptor.isRequiresReports() );
mojoDescriptor.setRequiresReports( value );
// Aggregator flag
DocletTag aggregator = findInClassHierarchy( javaClass, JavaMojoAnnotation.AGGREGATOR );
if ( aggregator != null )
{
mojoDescriptor.setAggregator( true );
} }
// requiresDirectInvocation flag // requiresDirectInvocation flag
@ -326,11 +312,33 @@ public class JavaMojoDescriptorExtractor
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_ONLINE, mojoDescriptor.isOnlineRequired() ); getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_ONLINE, mojoDescriptor.isOnlineRequired() );
mojoDescriptor.setOnlineRequired( value ); mojoDescriptor.setOnlineRequired( value );
// inheritByDefault flag // Project flag
value = value =
getBooleanTagValue( javaClass, JavaMojoAnnotation.INHERIT_BY_DEFAULT, getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_PROJECT, mojoDescriptor.isProjectRequired() );
mojoDescriptor.isInheritedByDefault() ); mojoDescriptor.setProjectRequired( value );
mojoDescriptor.setInheritedByDefault( value );
// requiresReports flag
value =
getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_REPORTS, mojoDescriptor.isRequiresReports() );
mojoDescriptor.setRequiresReports( value );
// ----------------------------------------------------------------------
// Javadoc annotations in alphabetical order
// ----------------------------------------------------------------------
// Deprecation hint
DocletTag deprecated = javaClass.getTagByName( JavaMojoAnnotation.DEPRECATED );
if ( deprecated != null )
{
mojoDescriptor.setDeprecated( deprecated.getValue() );
}
// What version it was introduced in
DocletTag since = findInClassHierarchy( javaClass, JavaMojoAnnotation.SINCE );
if ( since != null )
{
mojoDescriptor.setSince( since.getValue() );
}
extractParameters( mojoDescriptor, javaClass ); extractParameters( mojoDescriptor, javaClass );
@ -427,7 +435,6 @@ public class JavaMojoDescriptorExtractor
pd.setDescription( field.getComment() ); pd.setDescription( field.getComment() );
DocletTag componentTag = field.getTagByName( JavaMojoAnnotation.COMPONENT ); DocletTag componentTag = field.getTagByName( JavaMojoAnnotation.COMPONENT );
if ( componentTag != null ) if ( componentTag != null )
{ {
String role = componentTag.getNamedParameter( JavaMojoAnnotation.COMPONENT_ROLE ); String role = componentTag.getNamedParameter( JavaMojoAnnotation.COMPONENT_ROLE );