Author: brett
Date: Sun Jun 19 20:39:42 2005
New Revision: 191385

URL: http://svn.apache.org/viewcvs?rev=191385&view=rev
Log:
PR: MNG-471
add @execute phase|lifecycle doclet tag for java and beanshell
not sure how this would be configured for marmalade - will leave this for a 
once over of marmalade wrt the mojo api later

Modified:
    
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
    
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
    
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh
    
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java

Modified: 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java?rev=191385&r1=191384&r2=191385&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
 (original)
+++ 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
 Sun Jun 19 20:39:42 2005
@@ -36,7 +36,6 @@
     extends ComponentDescriptor
     implements Cloneable
 {
-    // TODO: share with type handler
     public static String MAVEN_PLUGIN = "maven-plugin";
 
     public static final String SINGLE_PASS_EXEC_STRATEGY = "once-per-session";
@@ -59,6 +58,8 @@
 
     private String executePhase;
 
+    private String executeLifecycle;
+
     private String deprecated;
 
     // ----------------------------------------------------------------------
@@ -374,5 +375,15 @@
         }
 
         return result;
+    }
+
+    public String getExecuteLifecycle()
+    {
+        return executeLifecycle;
+    }
+
+    public void setExecuteLifecycle( String executeLifecycle )
+    {
+        this.executeLifecycle = executeLifecycle;
     }
 }

Modified: 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java?rev=191385&r1=191384&r2=191385&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
 (original)
+++ 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
 Sun Jun 19 20:39:42 2005
@@ -33,7 +33,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-
 /**
  * @todo share constants
  * @todo add example usage tag that can be shown in the doco

Modified: 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh?rev=191385&r1=191384&r2=191385&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh
 (original)
+++ 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh
 Sun Jun 19 20:39:42 2005
@@ -3,6 +3,7 @@
 import java.io.FileReader;
 import org.codehaus.plexus.util.StringUtils;
 import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
 
 // only on start of line
 this.tag = "\\r?\\n\\s*\\*?\\s*@(\\w+)";
@@ -13,6 +14,8 @@
 this.descriptionPattern = Pattern.compile( "(?s)\\r?\\n\\s*\\*" );
 this.typePattern = Pattern.compile( "type\\s*=\\s*\"(.*?)\"" );
 this.expressionPattern = Pattern.compile( "expression\\s*=\\s*\"(.*?)\"" );
+this.phasePattern = Pattern.compile( "phase\\s*=\\s*\"(.*?)\"" );
+this.lifecyclePattern = Pattern.compile( "lifecycle\\s*=\\s*\"(.*?)\"" );
 
 setAccessibility( true );
 
@@ -135,7 +138,6 @@
         this.tags = getTags( text );
         mojoDescriptor.setGoal( tags.get( "goal" ) );
         mojoDescriptor.setPhase( tags.get( "phase" ) );
-        mojoDescriptor.setExecutePhase( tags.get( "executePhase" ) );
         this.value = tags.get( "requiresDependencyResolution" );
         // TODO: share with java extractor
         if ( value == null || value.length() == 0 )
@@ -146,6 +148,26 @@
 
         mojoDescriptor.setProjectRequired( tags.containsKey( "requiresProject" 
) );
         mojoDescriptor.setOnlineRequired( tags.containsKey( "requiresOnline" ) 
);
+
+        this.value = tags.get( "execute" );
+        if ( value != null )
+        {
+            m = phasePattern.matcher( value );
+            if ( m.find() )
+            {
+                mojoDescriptor.setExecutePhase( m.group( 1 ) );
+            }
+            else
+            {
+                throw new InvalidPluginDescriptorException( "@execute must 
have a phase" );
+            }
+
+            m = lifecyclePattern.matcher( value );
+            if ( m.find() )
+            {
+                mojoDescriptor.setExecuteLifecycle( m.group( 1 ) );
+            }
+        }
     }
 }
 

Modified: 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java?rev=191385&r1=191384&r2=191385&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
 (original)
+++ 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
 Sun Jun 19 20:39:42 2005
@@ -69,7 +69,7 @@
 
     public static final String PHASE = "phase";
 
-    public static final String EXECUTE_PHASE = "executePhase";
+    public static final String EXECUTE = "execute";
 
     public static final String GOAL_DESCRIPTION = "description";
 
@@ -184,11 +184,29 @@
         // Additional phase to execute first
         // 
----------------------------------------------------------------------
 
-        DocletTag executePhase = findInClassHierarchy( javaClass, 
EXECUTE_PHASE );
+        DocletTag oldExecutePhase = findInClassHierarchy( javaClass, 
"executePhase" );
+        if ( oldExecutePhase != null )
+        {
+            getLogger().warn( "DEPRECATED: @executePhase is deprecated, please 
use @execute" );
+            mojoDescriptor.setExecutePhase( oldExecutePhase.getValue() );
+        }
 
-        if ( executePhase != null )
+        DocletTag execute = findInClassHierarchy( javaClass, EXECUTE );
+
+        if ( execute != null )
         {
-            mojoDescriptor.setExecutePhase( executePhase.getValue() );
+            String executePhase = execute.getNamedParameter( "phase" );
+            if ( executePhase == null )
+            {
+                throw new InvalidPluginDescriptorException( "@execute tag 
requires a 'phase' parameter" );
+            }
+            mojoDescriptor.setExecutePhase( executePhase );
+
+            String lifecycle = execute.getNamedParameter( "lifecycle" );
+            if ( lifecycle != null )
+            {
+                mojoDescriptor.setExecuteLifecycle( lifecycle );
+            }
         }
 
         // 
----------------------------------------------------------------------
@@ -268,9 +286,7 @@
         // We're resolving class-level, ancestor-class-field, 
local-class-field order here.
         // 
---------------------------------------------------------------------------------
 
-        Map rawParams = new TreeMap();
-
-        extractFieldParameterTags( javaClass, rawParams );
+        Map rawParams = extractFieldParameterTags( javaClass );
 
         for ( Iterator it = rawParams.entrySet().iterator(); it.hasNext(); )
         {
@@ -314,15 +330,21 @@
         }
     }
 
-    private void extractFieldParameterTags( JavaClass javaClass, Map rawParams 
)
+    private Map extractFieldParameterTags( JavaClass javaClass )
     {
+        Map 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 )
         {
-            extractFieldParameterTags( superClass, rawParams );
+            rawParams = extractFieldParameterTags( superClass );
+        }
+        else
+        {
+            rawParams = new TreeMap();
         }
 
         JavaField[] classFields = javaClass.getFields();
@@ -341,7 +363,7 @@
                 }
             }
         }
-
+        return rawParams;
     }
 
     private JavaClass getJavaClass( JavaSource javaSource )
@@ -353,8 +375,6 @@
         throws InvalidPluginDescriptorException
     {
         JavaDocBuilder builder = new JavaDocBuilder();
-
-        File basedir = project.getBasedir();
 
         for ( Iterator i = project.getCompileSourceRoots().iterator(); 
i.hasNext(); )
         {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to