maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase GoalAttainmentPhase.java GoalResolutionPhase.java
Date Thu, 17 Jun 2004 14:45:47 GMT
jvanzyl     2004/06/17 07:45:47

  Modified:    maven-core/src/main/java/org/apache/maven/lifecycle
                        MavenLifecycleContext.java
               maven-core/src/main/java/org/apache/maven/lifecycle/phase
                        GoalAttainmentPhase.java GoalResolutionPhase.java
  Log:
  o broke up the goal attainment into a:
  
    goal resolution phase
    goal attainment phase
  
    This in part to help with John's work on cleanly separating the goal
    decoration phase
  
  o put some helper code into the maven lifecycle context so that phases can
    get information about goals and plugin descriptors without having to
    lookup the plugin manager. and i want to hide the plugin manager anyway.
  
    eventually people will be making their own phases so i'm trying to make
    them as convenient as possible.
  
  o it is now possible to access any plexus component within a phase by using
    the context.lookup(role[,roleHint]) method. so a phase now can take
    advantage of any component.
  
  Revision  Changes    Path
  1.4       +44 -1     maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecycleContext.java
  
  Index: MavenLifecycleContext.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecycleContext.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MavenLifecycleContext.java	17 Jun 2004 00:07:23 -0000	1.3
  +++ MavenLifecycleContext.java	17 Jun 2004 14:45:47 -0000	1.4
  @@ -3,9 +3,13 @@
   import org.apache.maven.project.MavenProject;
   import org.apache.maven.script.MavenScript;
   import org.apache.maven.plugin.descriptor.Goal;
  +import org.apache.maven.plugin.PluginManager;
   import org.codehaus.plexus.PlexusContainer;
   import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
   
  +import java.util.List;
  +import java.util.Map;
  +
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
  @@ -20,13 +24,20 @@
   
       private Goal goal;
   
  +    private List resolvedGoals;
  +
  +    private PluginManager pluginManager;
  +
       public MavenLifecycleContext( PlexusContainer container, MavenProject project, Goal
goal )
  +        throws Exception
       {
           this.container = container;
   
           this.project = project;
   
           this.goal = goal;
  +
  +        pluginManager = (PluginManager) lookup( PluginManager.ROLE );
       }
   
       // ----------------------------------------------------------------------
  @@ -88,4 +99,36 @@
           this.script = script;
       }
   
  +    // ----------------------------------------------------------------------
  +    // Resolved goals
  +    // ----------------------------------------------------------------------
  +
  +    public List getResolvedGoals()
  +    {
  +        return resolvedGoals;
  +    }
  +
  +    public void setResolvedGoals( List resolvedGoals )
  +    {
  +        this.resolvedGoals = resolvedGoals;
  +    }
  +
  +    // ----------------------------------------------------------------------
  +    // Delegation to the plugin manager
  +    // ----------------------------------------------------------------------
  +
  +    public Goal getGoal( String goalName )
  +    {
  +        return pluginManager.getGoal( goalName );
  +    }
  +
  +    public Map createParameters( Goal goal )
  +    {
  +        return pluginManager.createParameters( goal, project );
  +    }
  +
  +    public String getPluginId( Goal goal )
  +    {
  +        return pluginManager.getPluginDescriptor( goal.getName() ).getId();
  +    }
   }
  
  
  
  1.4       +7 -13     maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalAttainmentPhase.java
  
  Index: GoalAttainmentPhase.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalAttainmentPhase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GoalAttainmentPhase.java	17 Jun 2004 01:16:02 -0000	1.3
  +++ GoalAttainmentPhase.java	17 Jun 2004 14:45:47 -0000	1.4
  @@ -1,19 +1,17 @@
   package org.apache.maven.lifecycle.phase;
   
  +import org.apache.maven.artifact.collector.ArtifactCollectionResult;
  +import org.apache.maven.artifact.collector.ArtifactCollector;
   import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
   import org.apache.maven.lifecycle.MavenLifecycleContext;
   import org.apache.maven.plugin.Plugin;
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  -import org.apache.maven.plugin.PluginManager;
   import org.apache.maven.plugin.descriptor.Goal;
   import org.apache.maven.project.MavenProject;
   import org.apache.maven.project.MavenProjectBuilder;
  -import org.apache.maven.artifact.collector.ArtifactCollector;
  -import org.apache.maven.artifact.collector.ArtifactCollectionResult;
   
   import java.util.Iterator;
  -import java.util.List;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  @@ -25,21 +23,17 @@
       public void execute( MavenLifecycleContext context )
           throws Exception
       {
  -        PluginManager pluginManager = (PluginManager) context.getContainer().lookup( PluginManager.ROLE
);
  -
  -        List goals = pluginManager.getGoals( context.getGoal().getName() );
  -
           PluginExecutionResponse response;
   
           PluginExecutionRequest request;
   
           boolean transitiveDependenciesResolved = false;
   
  -        for ( Iterator it = goals.iterator(); it.hasNext(); )
  +        for ( Iterator it = context.getResolvedGoals().iterator(); it.hasNext(); )
           {
               String goalName = (String) it.next();
   
  -            Goal goal = pluginManager.getGoal( goalName );
  +            Goal goal = context.getGoal( goalName );
   
               System.out.println( "[" + goal.getName() + "]" );
   
  @@ -50,13 +44,13 @@
                   transitiveDependenciesResolved = true;
               }
   
  -            request = new PluginExecutionRequest( pluginManager.createParameters( goal,
context.getProject() ) );
  +            request = new PluginExecutionRequest( context.createParameters( goal ) );
   
               response = new PluginExecutionResponse();
   
               try
               {
  -                Plugin plugin = (Plugin) context.lookup( Plugin.ROLE, pluginManager.getPluginDescriptor(
goal.getName() ).getId() );
  +                Plugin plugin = (Plugin) context.lookup( Plugin.ROLE, context.getPluginId(
goal ) );
   
                   plugin.execute( request, response );
               }
  
  
  
  1.2       +9 -1      maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalResolutionPhase.java
  
  Index: GoalResolutionPhase.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalResolutionPhase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GoalResolutionPhase.java	11 Jun 2004 15:11:54 -0000	1.1
  +++ GoalResolutionPhase.java	17 Jun 2004 14:45:47 -0000	1.2
  @@ -2,6 +2,9 @@
   
   import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
   import org.apache.maven.lifecycle.MavenLifecycleContext;
  +import org.apache.maven.plugin.PluginManager;
  +
  +import java.util.List;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  @@ -13,5 +16,10 @@
       public void execute( MavenLifecycleContext context )
           throws Exception
       {
  +        PluginManager pluginManager = (PluginManager) context.getContainer().lookup( PluginManager.ROLE
);
  +
  +        List goals = pluginManager.getGoals( context.getGoal().getName() );
  +
  +        context.setResolvedGoals( goals );
       }
   }
  
  
  

Mime
View raw message