maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java JavaMojoDescriptorExtractor.java
Date Sun, 27 Feb 2005 05:39:55 GMT
brett       2005/02/26 21:39:55

  Modified:    maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator
                        PluginDescriptorGenerator.java
               maven-model pom.xml
               maven-plugin/src/main/java/org/apache/maven/plugin/descriptor
                        MojoDescriptor.java PluginDescriptorBuilder.java
               maven-core/src/main/java/org/apache/maven/lifecycle
                        DefaultLifecycleExecutor.java
                        LifecycleExecutor.java Phase.java
               maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java
               maven-core/src/main/resources/META-INF/plexus components.xml
               maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin
                        DescriptorGeneratorMojo.java PluginInstallMojo.java
               maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java
                        JavaMojoDescriptorExtractor.java
  Log:
  start to enhance the lifecycle. Need to pre-process plugins as currently goals are only
executed if added to a phase after the current goal. Also need plugin configuration to activate
these changes.
  
  Revision  Changes    Path
  1.4       +11 -0     maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
  
  Index: PluginDescriptorGenerator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PluginDescriptorGenerator.java	25 Feb 2005 05:09:14 -0000	1.3
  +++ PluginDescriptorGenerator.java	27 Feb 2005 05:39:55 -0000	1.4
  @@ -103,6 +103,15 @@
           //
           // ----------------------------------------------------------------------
   
  +        if ( mojoDescriptor.getPhase() != null )
  +        {
  +            element( w, "phase", mojoDescriptor.getPhase() );
  +        }
  +
  +        // ----------------------------------------------------------------------
  +        //
  +        // ----------------------------------------------------------------------
  +
           w.startElement( "implementation" );
   
           w.writeText( mojoDescriptor.getImplementation() );
  @@ -176,6 +185,8 @@
           // Prereqs
           // ----------------------------------------------------------------------
   
  +        // TODO: remove
  +
           List prereqs = mojoDescriptor.getPrereqs();
   
           if ( prereqs != null && prereqs.size() > 0 )
  
  
  
  1.4       +9 -0      maven-components/maven-model/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-model/pom.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- pom.xml	5 Jul 2004 20:12:50 -0000	1.3
  +++ pom.xml	27 Feb 2005 05:39:55 -0000	1.4
  @@ -13,4 +13,13 @@
     <version>2.0-SNAPSHOT</version>
     <description>Maven Model</description>
     <shortDescription>Maven Model</shortDescription>
  +  <plugins>
  +    <plugin>
  +      <id>modello</id>
  +      <configuration>
  +        <model>maven.mdo</model>
  +        <version>4.0.0</version>
  +      </configuration>
  +    </plugin>
  +  </plugins>
   </project>
  
  
  
  1.5       +13 -0     maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
  
  Index: MojoDescriptor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MojoDescriptor.java	20 Feb 2005 16:25:21 -0000	1.4
  +++ MojoDescriptor.java	27 Feb 2005 05:39:55 -0000	1.5
  @@ -46,6 +46,8 @@
   
       private String goal;
   
  +    private String phase;
  +
       // ----------------------------------------------------------------------
       //
       // ----------------------------------------------------------------------
  @@ -190,6 +192,16 @@
       //
       // ----------------------------------------------------------------------
   
  +    public String getPhase()
  +    {
  +        return phase;
  +    }
  +
  +    public void setPhase( String phase )
  +    {
  +        this.phase = phase;
  +    }
  +
       public String getGoal()
       {
           return goal;
  @@ -223,6 +235,7 @@
           }
           catch ( Exception e )
           {
  +            // TODO: this needs better handling
           }
   
           return null;
  
  
  
  1.6       +8 -1      maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
  
  Index: PluginDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PluginDescriptorBuilder.java	20 Feb 2005 16:25:21 -0000	1.5
  +++ PluginDescriptorBuilder.java	27 Feb 2005 05:39:55 -0000	1.6
  @@ -87,6 +87,13 @@
               mojo.setLanguage( langConfig.getValue() );
           }
   
  +        String phase = c.getChild( "phase" ).getValue();
  +
  +        if ( phase != null )
  +        {
  +            mojo.setPhase( phase );
  +        }
  +
           mojo.setInstantiationStrategy( c.getChild( "instantiationStrategy" ).getValue()
);
   
           mojo.setDescription( c.getChild( "description" ).getValue() );
  
  
  
  1.5       +23 -9     maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
  
  Index: DefaultLifecycleExecutor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultLifecycleExecutor.java	25 Feb 2005 03:14:49 -0000	1.4
  +++ DefaultLifecycleExecutor.java	27 Feb 2005 05:39:55 -0000	1.5
  @@ -28,9 +28,11 @@
   
   import java.util.Date;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Set;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  @@ -70,6 +72,7 @@
   
           response.setStart( new Date() );
   
  +        Set seenPhases = new HashSet();
           try
           {
               for ( Iterator i = tasks.iterator(); i.hasNext(); )
  @@ -109,20 +112,26 @@
       protected void executePhase( String phase, MavenSession session, MavenExecutionResponse
response )
           throws LifecycleExecutionException
       {
  -        int i = phases.indexOf( phaseMap.get( phase ) );
  +        // only execute up to the given phase
  +        int index = phases.indexOf( phaseMap.get( phase ) );
   
  -        for ( int j = 0; j <= i; j++ )
  +        for ( int j = 0; j <= index; j++ )
           {
               Phase p = (Phase) phases.get( j );
   
  -            if ( p.getGoal() != null )
  +            if ( p.getGoals() != null )
               {
  -                PluginExecutionResponse pluginResponse = executeMojo( p.getGoal(), session
);
  -
  -                if ( pluginResponse.isExecutionFailure() )
  +                for ( Iterator i = p.getGoals().iterator(); i.hasNext(); )
                   {
  -                    response.setExecutionFailure( p.getGoal(), pluginResponse.getFailureResponse()
);
  -                    break;
  +                    String goal = (String) i.next();
  +
  +                    PluginExecutionResponse pluginResponse = executeMojo( goal, session
);
  +
  +                    if ( pluginResponse.isExecutionFailure() )
  +                    {
  +                        response.setExecutionFailure( goal, pluginResponse.getFailureResponse()
);
  +                        break;
  +                    }
                   }
               }
           }
  @@ -159,6 +168,11 @@
           return phases;
       }
   
  +    public Phase getPhase( String id )
  +    {
  +        return (Phase) phaseMap.get( id );
  +    }
  +
       // ----------------------------------------------------------------------
       // Lifecylce Management
       // ----------------------------------------------------------------------
  
  
  
  1.3       +3 -1      maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
  
  Index: LifecycleExecutor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LifecycleExecutor.java	25 Feb 2005 03:14:49 -0000	1.2
  +++ LifecycleExecutor.java	27 Feb 2005 05:39:55 -0000	1.3
  @@ -34,4 +34,6 @@
           throws LifecycleExecutionException;
   
       List getPhases();
  +
  +    Phase getPhase( String id );    
   }
  
  
  
  1.2       +12 -5     maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/Phase.java
  
  Index: Phase.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/Phase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Phase.java	16 Feb 2005 07:16:32 -0000	1.1
  +++ Phase.java	27 Feb 2005 05:39:55 -0000	1.2
  @@ -1,5 +1,8 @@
   package org.apache.maven.lifecycle;
   
  +import java.util.HashSet;
  +import java.util.Set;
  +
   /* ====================================================================
    *   Copyright 2001-2004 The Apache Software Foundation.
    *
  @@ -23,17 +26,21 @@
    */
   public class Phase
   {
  -    String id;
  +    private String id;
   
  -    String goal;
  +    private Set goals;
   
       public String getId()
       {
           return id;
       }
   
  -    public String getGoal()
  +    public Set getGoals()
       {
  -        return goal;
  +        if ( goals == null )
  +        {
  +            goals = new HashSet();
  +        }
  +        return goals;
       }
   }
  
  
  
  1.31      +27 -0     maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
  
  Index: DefaultPluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DefaultPluginManager.java	25 Feb 2005 03:14:49 -0000	1.30
  +++ DefaultPluginManager.java	27 Feb 2005 05:39:55 -0000	1.31
  @@ -28,6 +28,8 @@
   import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
   import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
   import org.apache.maven.execution.MavenSession;
  +import org.apache.maven.lifecycle.LifecycleExecutor;
  +import org.apache.maven.lifecycle.Phase;
   import org.apache.maven.lifecycle.goal.GoalExecutionException;
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
   import org.apache.maven.plugin.descriptor.Parameter;
  @@ -81,6 +83,9 @@
   
       protected MavenProjectBuilder mavenProjectBuilder;
   
  +    // TODO: remove
  +    private LifecycleExecutor lifecycleExecutor;
  +
       public DefaultPluginManager()
       {
           mojoDescriptors = new HashMap();
  @@ -136,6 +141,24 @@
   
               MojoDescriptor mojoDescriptor = mavenMojoDescriptor.getMojoDescriptor();
   
  +            String id = mojoDescriptor.getPhase();
  +
  +            if ( id != null )
  +            {
  +                Phase phase = lifecycleExecutor.getPhase( id );
  +
  +                if ( phase != null )
  +                {
  +                    // TODO: remove debugging
  +                    System.err.println( "adding " + mavenMojoDescriptor.getId() + " to
phase " + phase.getId() );
  +                    phase.getGoals().add( mavenMojoDescriptor.getId() );
  +                }
  +                else
  +                {
  +                    // TODO: this should fail
  +                }
  +            }
  +
               mojoDescriptors.put( mojoDescriptor.getId(), mojoDescriptor );
   
               pluginDescriptors.put( pluginDescriptor.getId(), pluginDescriptor );
  @@ -210,10 +233,14 @@
       protected void addPlugin( Artifact pluginArtifact, MavenSession session )
           throws Exception
       {
  +        // TODO: these should be configured, not instantiated here
  +
           artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
   
           mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE
);
   
  +        lifecycleExecutor = (LifecycleExecutor) container.lookup( LifecycleExecutor.ROLE
);
  +
           MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver,
                                                                         mavenProjectBuilder
);
   
  
  
  
  1.15      +24 -8     maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml
  
  Index: components.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- components.xml	23 Feb 2005 23:59:27 -0000	1.14
  +++ components.xml	27 Feb 2005 05:39:55 -0000	1.15
  @@ -209,12 +209,16 @@
             <!-- 4 -->
             <phase>
               <id>process-resources</id>
  -            <goal>resources:resources</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">resources:resources</goal>
  +            </goals>
             </phase>
             <!-- 5 -->
             <phase>
               <id>compile</id>
  -            <goal>compiler:compile</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">compiler:compile</goal>
  +            </goals>
             </phase>
             <!-- 6 -->
             <phase>
  @@ -235,32 +239,44 @@
             <!-- 10 -->
             <phase>
               <id>process-test-resources</id>
  -            <goal>resources:testResources</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">resources:testResources</goal>
  +            </goals>
             </phase>
             <!-- 11 -->
             <phase>
               <id>test-compile</id>
  -            <goal>compiler:testCompile</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">compiler:testCompile</goal>
  +            </goals>
             </phase>
             <!-- 12 -->
             <phase>
               <id>test</id>
  -            <goal>surefire:test</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">surefire:test</goal>
  +            </goals>
             </phase>
             <!-- 13 -->
             <phase>
               <id>package</id>
  -            <goal>jar:jar</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">jar:jar</goal>
  +            </goals>
             </phase>
             <!-- 14 -->
             <phase>
               <id>install</id>
  -            <goal>install:install</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">install:install</goal>
  +            </goals>
             </phase>
             <!-- 15 -->
             <phase>
               <id>deploy</id>
  -            <goal>deploy:deploy</goal>
  +            <goals>
  +              <goal implementation="java.lang.String">deploy:deploy</goal>
  +            </goals>
             </phase>
           </phases>
           <!-- END SNIPPET: lifecycle -->
  
  
  
  1.2       +4 -1      maven-components/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
  
  Index: DescriptorGeneratorMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DescriptorGeneratorMojo.java	20 Feb 2005 16:25:20 -0000	1.1
  +++ DescriptorGeneratorMojo.java	27 Feb 2005 05:39:55 -0000	1.2
  @@ -8,6 +8,8 @@
   /**
    * @goal descriptor
    *
  + * @phase process-sources
  + *
    * @description Goal for generating a plugin descriptor.
    *
    * @parameter
  @@ -44,5 +46,6 @@
           PluginDescriptorGenerator generator = new PluginDescriptorGenerator();
   
           generator.execute( outputDirectory, mavenMojoDescriptors, project );
  +
       }
   }
  
  
  
  1.7       +2 -1      maven-components/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java
  
  Index: PluginInstallMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PluginInstallMojo.java	5 Sep 2004 19:03:41 -0000	1.6
  +++ PluginInstallMojo.java	27 Feb 2005 05:39:55 -0000	1.7
  @@ -37,6 +37,7 @@
    *
    * @prereq plugin:descriptor
    * @prereq jar:jar
  + * @todo should be replaced by install:install
    */
   public class PluginInstallMojo
       extends AbstractPlugin
  @@ -52,7 +53,7 @@
   
           if ( ! "plugin".equals( project.getType() ) )
           {
  -            response.setExecutionFailure( true, new PluginFailureResponse( "This project
isn't a plugin." ) );
  +            response.setExecutionFailure( new PluginFailureResponse( "This project isn't
a plugin." ) );
   
               return;
           }
  
  
  
  1.3       +17 -5     maven-components/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
  
  Index: JavaMojoDescriptorExtractor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaMojoDescriptorExtractor.java	24 Feb 2005 05:12:30 -0000	1.2
  +++ JavaMojoDescriptorExtractor.java	27 Feb 2005 05:39:55 -0000	1.3
  @@ -16,6 +16,10 @@
    * limitations under the License.
    */
   
  +import com.thoughtworks.qdox.JavaDocBuilder;
  +import com.thoughtworks.qdox.model.DocletTag;
  +import com.thoughtworks.qdox.model.JavaClass;
  +import com.thoughtworks.qdox.model.JavaSource;
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
   import org.apache.maven.plugin.descriptor.Parameter;
   import org.apache.maven.project.MavenProject;
  @@ -23,11 +27,6 @@
   import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
   import org.apache.maven.tools.plugin.util.PluginUtils;
   
  -import com.thoughtworks.qdox.JavaDocBuilder;
  -import com.thoughtworks.qdox.model.DocletTag;
  -import com.thoughtworks.qdox.model.JavaClass;
  -import com.thoughtworks.qdox.model.JavaSource;
  -
   import java.io.File;
   import java.util.ArrayList;
   import java.util.HashSet;
  @@ -54,6 +53,8 @@
   
       public static final String GOAL = "goal";
   
  +    public static final String PHASE = "phase";
  +
       public static final String DISPATCH = "dispatch";
   
       public static final String GOAL_DESCRIPTION = "description";
  @@ -161,6 +162,17 @@
           }
   
           // ----------------------------------------------------------------------
  +        // Phase name
  +        // ----------------------------------------------------------------------
  +
  +        DocletTag phase = javaClass.getTagByName( PHASE );
  +
  +        if ( phase != null )
  +        {
  +            mojoDescriptor.setPhase( phase.getValue() );
  +        }
  +
  +        // ----------------------------------------------------------------------
           // Dependency resolution flag
           // ----------------------------------------------------------------------
   
  
  
  

Mime
View raw message