jvanzyl     2004/02/14 17:42:30

  Modified:    maven-core/src/java/org/apache/maven/plugin
                        DefaultPluginManagerManager.java
                        PluginDescriptor.java PluginManager.java
               maven-core/src/java/org/apache/maven/plugin/plexus
                        PlexusPluginManager.java
  Log:
  o build the goal -> plugin map inside the plugin manager manager, then we
    just send in the id of the plugin let the implementation take care of
    finding the correct plugin to execute.
  
  Revision  Changes    Path
  1.6       +7 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultPluginManagerManager.java  15 Feb 2004 01:28:33 -0000      1.5
  +++ DefaultPluginManagerManager.java  15 Feb 2004 01:42:30 -0000      1.6
  @@ -112,6 +112,8 @@
   
       protected Map goalMap;
   
  +    protected Map goalToPluginMap;
  +
       public DefaultPluginManagerManager()
       {
           xstream = new XStream( new JavaReflectionObjectFactory(),
  @@ -128,6 +130,8 @@
           xstream.alias( "prereq", String.class );
   
           goalMap = new HashMap();
  +
  +        goalToPluginMap = new HashMap();
       }
   
       public void attainGoals( MavenProject project, List goalNames )
  @@ -163,7 +167,7 @@
   
                   String g = (String) goals.get( j );
   
  -                pluginManager.attainGoal( g, collectParameters( g, project ) );
  +                pluginManager.attainGoal( (String) goalToPluginMap.get( g ), 
collectParameters( g, project ) );
               }
           }
       }
  @@ -209,6 +213,8 @@
                   }
   
                   goalMap.put( g.getName(), g );
  +
  +                goalToPluginMap.put( g.getName(), pd.getId() );
               }
           }
       }
  
  
  
  1.3       +7 -0      
maven-components/maven-core/src/java/org/apache/maven/plugin/PluginDescriptor.java
  
  Index: PluginDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/java/org/apache/maven/plugin/PluginDescriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PluginDescriptor.java     15 Feb 2004 01:28:33 -0000      1.2
  +++ PluginDescriptor.java     15 Feb 2004 01:42:30 -0000      1.3
  @@ -11,11 +11,18 @@
    */
   public class PluginDescriptor
   {
  +    private String id;
  +
       private List goals;
   
       public List getGoals()
       {
           return goals;
  +    }
  +
  +    public String getId()
  +    {
  +        return id;
       }
   
       public static class Goal
  
  
  
  1.4       +1 -1      
maven-components/maven-core/src/java/org/apache/maven/plugin/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PluginManager.java        15 Feb 2004 01:16:44 -0000      1.3
  +++ PluginManager.java        15 Feb 2004 01:42:30 -0000      1.4
  @@ -18,7 +18,7 @@
   {
       static String ROLE = PluginManager.class.getName();
   
  -    void attainGoal( String goal, Map parameters )
  +    void attainGoal( String pluginId, Map parameters )
           throws GoalException, Exception;
   
       List getGoals();
  
  
  
  1.8       +2 -27     
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PlexusPluginManager.java  15 Feb 2004 01:16:44 -0000      1.7
  +++ PlexusPluginManager.java  15 Feb 2004 01:42:30 -0000      1.8
  @@ -4,7 +4,6 @@
   import org.apache.maven.plugin.AbstractPluginManager;
   
   import java.lang.reflect.Method;
  -import java.util.HashMap;
   import java.util.Map;
   
   /**
  @@ -19,38 +18,14 @@
   {
       private Map plugins;
   
  -    private Map goalToPluginMap;
  -
  -    // parameters can be extracted from the MavenProject itself
  -    // or from properties or good old hard coded values.
  -
  -    // For anyone looking this code in the constructor here will be moved to the
  -    // abstract plugin manager and the values I have hardcoded here in maps will
  -    // come from a generated descriptor of some sort. So for java plugins we could
  -    // simply use @tags and qdox to generate the metadata for the parameter names
  -    // and types. The would obviously be required for maven itself but would also
  -    // prove useful for other tools trying to use maven now that this version is
  -    // completely embeddable.
  -
       public PlexusPluginManager()
       {
  -        goalToPluginMap = new HashMap();
  -
  -        goalToPluginMap.put( "compile", "compiler" );
  -
  -        goalToPluginMap.put( "test:compile", "compiler" );
  -
  -        goalToPluginMap.put( "jar", "jar" );
  -
  -        goalToPluginMap.put( "test", "surefire" );
       }
   
  -    public void attainGoal( String goal, Map parameters )
  +    public void attainGoal( String pluginId, Map parameters )
           throws GoalException, Exception
       {
  -        String roleHint = (String) goalToPluginMap.get( goal );
  -
  -        Object plugin = plugins.get( roleHint );
  +        Object plugin = plugins.get( pluginId );
   
           System.out.println( "parameters = " + parameters );
   
  
  
  

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

Reply via email to