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-core/src/main/java/org/apache/maven/plugin DefaultPluginManager.java PluginManager.java
Date Sun, 27 Feb 2005 06:19:13 GMT
brett       2005/02/26 22:19:13

  Modified:    maven-core/src/main/java/org/apache/maven/lifecycle
                        DefaultLifecycleExecutor.java
               maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java PluginManager.java
  Log:
  pre-process plugins
  
  Revision  Changes    Path
  1.6       +58 -6     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultLifecycleExecutor.java	27 Feb 2005 05:39:55 -0000	1.5
  +++ DefaultLifecycleExecutor.java	27 Feb 2005 06:19:13 -0000	1.6
  @@ -23,16 +23,15 @@
   import org.apache.maven.lifecycle.goal.GoalExecutionException;
   import org.apache.maven.plugin.PluginExecutionResponse;
   import org.apache.maven.plugin.PluginManager;
  +import org.apache.maven.plugin.descriptor.MojoDescriptor;
   import org.apache.maven.project.MavenProjectBuilder;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
   
   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>
  @@ -72,9 +71,10 @@
   
           response.setStart( new Date() );
   
  -        Set seenPhases = new HashSet();
           try
           {
  +            preProcessPlugins( tasks, session );
  +
               for ( Iterator i = tasks.iterator(); i.hasNext(); )
               {
                   String task = (String) i.next();
  @@ -97,7 +97,7 @@
                   }
               }
           }
  -        catch ( LifecycleExecutionException e )
  +        catch ( Exception e )
           {
               response.setException( e );
           }
  @@ -109,7 +109,59 @@
           return response;
       }
   
  -    protected void executePhase( String phase, MavenSession session, MavenExecutionResponse
response )
  +    private void preProcessPlugins( List tasks, MavenSession session )
  +        throws Exception
  +    {
  +        for ( Iterator i = tasks.iterator(); i.hasNext(); )
  +        {
  +            String task = (String) i.next();
  +
  +            PluginExecutionResponse pluginResponse;
  +
  +            if ( phaseMap.containsKey( task ) )
  +            {
  +                // only execute up to the given phase
  +                int index = phases.indexOf( phaseMap.get( task ) );
  +
  +                for ( int j = 0; j <= index; j++ )
  +                {
  +                    Phase p = (Phase) phases.get( j );
  +
  +                    if ( p.getGoals() != null )
  +                    {
  +                        for ( Iterator k = p.getGoals().iterator(); k.hasNext(); )
  +                        {
  +                            String goal = (String) k.next();
  +
  +                            verifyMojoPhase( goal, session );
  +                        }
  +                    }
  +                }
  +            }
  +            else
  +            {
  +                verifyMojoPhase( task, session );
  +            }
  +        }
  +    }
  +
  +    private void verifyMojoPhase( String task, MavenSession session )
  +        throws Exception
  +    {
  +        MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( task );
  +        if ( mojoDescriptor == null )
  +        {
  +            pluginManager.verifyPluginForGoal( task, session );
  +            mojoDescriptor = pluginManager.getMojoDescriptor( task );
  +            if ( mojoDescriptor.getPhase() != null )
  +            {
  +                Phase phase = (Phase) phaseMap.get( mojoDescriptor.getPhase() );
  +                phase.getGoals().add( task );
  +            }
  +        }
  +    }
  +
  +    private void executePhase( String phase, MavenSession session, MavenExecutionResponse
response )
           throws LifecycleExecutionException
       {
           // only execute up to the given phase
  
  
  
  1.32      +0 -25     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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- DefaultPluginManager.java	27 Feb 2005 05:39:55 -0000	1.31
  +++ DefaultPluginManager.java	27 Feb 2005 06:19:13 -0000	1.32
  @@ -28,8 +28,6 @@
   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;
  @@ -83,9 +81,6 @@
   
       protected MavenProjectBuilder mavenProjectBuilder;
   
  -    // TODO: remove
  -    private LifecycleExecutor lifecycleExecutor;
  -
       public DefaultPluginManager()
       {
           mojoDescriptors = new HashMap();
  @@ -141,24 +136,6 @@
   
               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 );
  @@ -239,8 +216,6 @@
   
           mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE
);
   
  -        lifecycleExecutor = (LifecycleExecutor) container.lookup( LifecycleExecutor.ROLE
);
  -
           MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver,
                                                                         mavenProjectBuilder
);
   
  
  
  
  1.12      +4 -4      maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- PluginManager.java	25 Feb 2005 03:14:49 -0000	1.11
  +++ PluginManager.java	27 Feb 2005 06:19:13 -0000	1.12
  @@ -34,15 +34,15 @@
       PluginExecutionResponse executeMojo( MavenSession session, String goalName )
            throws GoalExecutionException;
   
  +    // TODO: not used - needs to be in interface?
       void processPluginDescriptor( MavenPluginDescriptor pluginDescriptor )
           throws Exception;
   
  -    // TODO: not currently used
  +    // TODO: not currently used - needs to be in interface?
       Map getMojoDescriptors();
   
  -    // TODO: not currently used (usages are in the phases that are no longer used)
       MojoDescriptor getMojoDescriptor( String goalId );
   
  -    void verifyPluginForGoal( String pluginId, MavenSession session )
  +    void verifyPluginForGoal( String goalName, MavenSession session )
           throws Exception;
   }
  
  
  

Mime
View raw message