You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2008/08/12 12:38:10 UTC

svn commit: r685111 - /maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java

Author: vsiveton
Date: Tue Aug 12 03:38:09 2008
New Revision: 685111

URL: http://svn.apache.org/viewvc?rev=685111&view=rev
Log:
MPLUGIN-134: Review the support of Mojo's annotations

o ordering annotations

Modified:
    maven/plugin-tools/trunk/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java

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=685111&r1=685110&r2=685111&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 Tue Aug 12 03:38:09 2008
@@ -201,20 +201,15 @@
         mojoDescriptor.setImplementation( javaClass.getFullyQualifiedName() );
         mojoDescriptor.setDescription( javaClass.getComment() );
 
-        // 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
+        // ----------------------------------------------------------------------
+        // Mojo annotations in alphabetical order
+        // ----------------------------------------------------------------------
+
+        // Aggregator flag
+        DocletTag aggregator = findInClassHierarchy( javaClass, JavaMojoAnnotation.AGGREGATOR );
+        if ( aggregator != null )
         {
-            mojoDescriptor.setExecutionStrategy( MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY );
+            mojoDescriptor.setAggregator( true );
         }
 
         // Configurator hint
@@ -224,34 +219,6 @@
             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
         DocletTag execute = findInClassHierarchy( javaClass, JavaMojoAnnotation.EXECUTE );
         if ( execute != null )
@@ -283,36 +250,55 @@
             }
         }
 
+        // 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
         DocletTag requiresDependencyResolution =
             findInClassHierarchy( javaClass, JavaMojoAnnotation.REQUIRES_DEPENDENCY_RESOLUTION );
         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 );
-        }
-
-        // 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 );
+            mojoDescriptor.setDependencyResolutionRequired( v );
         }
 
         // requiresDirectInvocation flag
@@ -326,11 +312,33 @@
             getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_ONLINE, mojoDescriptor.isOnlineRequired() );
         mojoDescriptor.setOnlineRequired( value );
 
-        // inheritByDefault flag
+        // Project flag
         value =
-            getBooleanTagValue( javaClass, JavaMojoAnnotation.INHERIT_BY_DEFAULT,
-                                mojoDescriptor.isInheritedByDefault() );
-        mojoDescriptor.setInheritedByDefault( value );
+            getBooleanTagValue( javaClass, JavaMojoAnnotation.REQUIRES_PROJECT, mojoDescriptor.isProjectRequired() );
+        mojoDescriptor.setProjectRequired( 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 );
 
@@ -427,7 +435,6 @@
             pd.setDescription( field.getComment() );
 
             DocletTag componentTag = field.getTagByName( JavaMojoAnnotation.COMPONENT );
-
             if ( componentTag != null )
             {
                 String role = componentTag.getNamedParameter( JavaMojoAnnotation.COMPONENT_ROLE );