jvanzyl     2004/02/14 13:33:00

  Modified:    maven-core/src/java/org/apache/maven/plugin
                        DefaultPluginManagerManager.java
               maven-core/src/java/org/apache/maven/plugin/plexus
                        PlexusPluginManager.java
  Log:
  o use the DAG in plexus for the goal chain execution calculation, add pre/post
    goals will be no problem.
  
  Revision  Changes    Path
  1.3       +31 -1     
maven-components/maven-core/src/java/org/apache/maven/plugin/DefaultPluginManagerManager.java
  
  Index: DefaultPluginManagerManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/java/org/apache/maven/plugin/DefaultPluginManagerManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultPluginManagerManager.java  12 Feb 2004 01:59:00 -0000      1.2
  +++ DefaultPluginManagerManager.java  14 Feb 2004 21:33:00 -0000      1.3
  @@ -65,6 +65,8 @@
   import org.codehaus.plexus.logging.AbstractLogEnabled;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
  +import org.codehaus.plexus.util.dag.DAG;
  +import org.codehaus.plexus.util.dag.TopologicalSorter;
   
   import java.util.Iterator;
   import java.util.List;
  @@ -90,8 +92,16 @@
   
       protected String mavenLocalHome;
   
  +    DAG dag = new DAG();
  +
       public DefaultPluginManagerManager()
       {
  +        // compile, test, test:compile
  +        dag.addEdge( "jar", "test" );
  +
  +        dag.addEdge( "test", "test:compile" );
  +
  +        dag.addEdge( "test:compile", "compile" );
       }
   
       public void attainGoals( MavenProject project, List goalNames )
  @@ -100,6 +110,12 @@
           // We have to look at each of the goals and find out which plugin manager
           // is responsible for a particular goal.
   
  +        // Track attained goals and optionally turn them on or off
  +
  +        // Need a clean goal
  +
  +        // find cycles
  +
           PluginManager pluginManager;
   
           pluginManager = (PluginManager) pluginManagers.get( "plexus" );
  @@ -108,7 +124,21 @@
           {
               String goal = (String) i.next();
   
  -            pluginManager.attainGoal( project, goal );
  +            List goals = TopologicalSorter.sort( dag );
  +
  +            int goalIndex = goals.indexOf( goal );
  +
  +            // execute all goals starting from the beginning of the chain
  +            // up to the goal specified.
  +
  +            for ( int j = 0; j <= goalIndex; j++ )
  +            {
  +                // Now dealing with whether the goal as been attained.
  +
  +                String g = (String) goals.get( j );
  +
  +                pluginManager.attainGoal( project, g );
  +            }
           }
       }
   
  
  
  
  1.6       +6 -5      
maven-components/maven-core/src/java/org/apache/maven/plugin/plexus/PlexusPluginManager.java
  
  Index: PlexusPluginManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/java/org/apache/maven/plugin/plexus/PlexusPluginManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PlexusPluginManager.java  14 Feb 2004 17:16:38 -0000      1.5
  +++ PlexusPluginManager.java  14 Feb 2004 21:33:00 -0000      1.6
  @@ -5,13 +5,12 @@
   import org.apache.maven.GoalException;
   import org.apache.maven.plugin.AbstractPluginManager;
   import org.apache.maven.plugin.ParameterCollectionException;
  -import org.apache.maven.plugin.Plugin;
   import org.apache.maven.project.MavenProject;
   
  +import java.lang.reflect.Method;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
  -import java.io.File;
   
   /**
    *
  @@ -127,7 +126,7 @@
       {
           String roleHint = (String) goalToPluginMap.get( goal );
   
  -        Plugin plugin = (Plugin) plugins.get( roleHint );
  +        Object plugin = plugins.get( roleHint );
   
           // Now this brings up the question of where do the parameters come from?
   
  @@ -135,7 +134,9 @@
   
           System.out.println( "parameters = " + parameters );
   
  -        plugin.execute( parameters );
  +        Method m = plugin.getClass().getMethod( "execute", new Class[]{ Map.class } 
);
  +
  +        m.invoke( plugin, new Object[]{ parameters } );
       }
   
       private Map collectParameters( String goal, MavenProject project )
  
  
  

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

Reply via email to