jvanzyl     2004/05/07 16:46:51

  Modified:    maven-core bootstrap.plugins
               maven-core/src/main/java/org/apache/maven/plugin
                        PluginExecutionRequest.java
               maven-core/src/main/java/org/apache/maven/plugin/manager
                        DefaultPluginManagerManager.java
               maven-core/src/main/java/org/apache/maven/plugin/plexus
                        FieldPluginConfigurator.java
                        PlexusPluginManager.java
                        SetterPluginConfigurator.java
               maven-core/src/main/java/org/apache/maven/plugin/plexus/executor
                        FieldPluginExecutor.java
                        IntegratedPluginExecutor.java
                        SetterPluginExecutor.java
               maven-core/src/test/java/org/apache/maven/plugin
                        PluginConfiguratorTest.java PluginTest.java
  Removed:     maven-core/src/main/java/org/apache/maven/plugin/plexus/executor
                        SingletonPluginExecutor.java
               maven-core/src/test/java/org/apache/maven/plugin
                        SingletonPlugin.java
               maven-core/src/test/resources/org/apache/maven/plugin
                        singleton-plugin.xml
  Log:
  o do the rework to remove any dependencies on maven from the plugin request
    and response. preparing to the little POJO package in a separate build
    so that it is clear that it does not depend on the maven core.
  
  o removed the singleton type.
  
  Revision  Changes    Path
  1.5       +1 -0      maven-components/maven-core/bootstrap.plugins
  
  Index: bootstrap.plugins
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/bootstrap.plugins,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- bootstrap.plugins 20 Apr 2004 14:06:57 -0000      1.4
  +++ bootstrap.plugins 7 May 2004 23:46:51 -0000       1.5
  @@ -6,3 +6,4 @@
   maven-scm-plugin
   maven-surefire-plugin
   maven-xdoc-plugin
  +maven-idea-plugin
  
  
  
  1.5       +10 -26    
maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionRequest.java
  
  Index: PluginExecutionRequest.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionRequest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PluginExecutionRequest.java       21 Mar 2004 00:33:17 -0000      1.4
  +++ PluginExecutionRequest.java       7 May 2004 23:46:51 -0000       1.5
  @@ -16,10 +16,7 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.plugin.descriptor.GoalDescriptor;
  -import org.apache.maven.plugin.descriptor.PluginDescriptor;
  -import org.apache.maven.project.MavenProject;
  -
  +import java.util.HashMap;
   import java.util.Map;
   
   /**
  @@ -33,23 +30,15 @@
   {
       private Map parameters;
   
  -    private GoalDescriptor goalDescriptor;
  -
  -    private PluginDescriptor pluginDescriptor;
  -
  -    private MavenProject project;
  +    private Map context;
   
       private Object plugin;
   
  -    public PluginExecutionRequest( PluginDescriptor pluginDescriptor,
  -                                   GoalDescriptor goalDescriptor,
  -                                   MavenProject project )
  +    public PluginExecutionRequest( Map parameters )
       {
  -        this.pluginDescriptor = pluginDescriptor;
  -
  -        this.goalDescriptor = goalDescriptor;
  +        context = new HashMap();
   
  -        this.project = project;
  +        this.parameters = parameters;
       }
   
       public Map getParameters()
  @@ -67,19 +56,14 @@
           return parameters.get( key );
       }
   
  -    public GoalDescriptor getGoalDescriptor()
  -    {
  -        return goalDescriptor;
  -    }
  -
  -    public PluginDescriptor getPluginDescriptor()
  +    public void addContextValue( Object key, Object value )
       {
  -        return pluginDescriptor;
  +        context.put( key, value );
       }
   
  -    public MavenProject getProject()
  +    public Object getContextValue( String key )
       {
  -        return project;
  +        return context.get( key );
       }
   
       public void setPlugin( Object plugin )
  
  
  
  1.13      +36 -2     
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/DefaultPluginManagerManager.java
  
  Index: DefaultPluginManagerManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/DefaultPluginManagerManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultPluginManagerManager.java  7 May 2004 19:58:39 -0000       1.12
  +++ DefaultPluginManagerManager.java  7 May 2004 23:46:51 -0000       1.13
  @@ -19,9 +19,12 @@
   import org.apache.maven.lifecycle.MavenLifecycleContext;
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  +import org.apache.maven.plugin.plexus.OgnlProjectValueExtractor;
   import org.apache.maven.plugin.descriptor.GoalDescriptor;
   import org.apache.maven.plugin.descriptor.PluginDescriptor;
   import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
  +import org.apache.maven.plugin.descriptor.ParameterDescriptor;
  +import org.apache.maven.project.MavenProject;
   import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
   import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
   import org.codehaus.plexus.logging.AbstractLogEnabled;
  @@ -126,15 +129,46 @@
   
           GoalDescriptor goalDescriptor = getGoalDescriptor( goal );
   
  -        PluginDescriptor pluginDescriptor = getPluginDescriptor( goal );
  +        PluginExecutionRequest request = new PluginExecutionRequest( 
createParameters( goalDescriptor, context.getProject() ) );
   
  -        PluginExecutionRequest request = new PluginExecutionRequest( 
pluginDescriptor, goalDescriptor );
  +        request.addContextValue( "id", getPluginDescriptor( goal ).getId() );
  +
  +        request.addContextValue( "mode", getPluginDescriptor( goal ).getMode() );
   
           PluginExecutionResponse response = new PluginExecutionResponse();
   
           pluginManager.attainGoal( request, response );
   
           return response;
  +    }
  +
  +    // ----------------------------------------------------------------------
  +    // Create parameters for plugin execution
  +    // ----------------------------------------------------------------------
  +    //!!! This could be moved to a utility class
  +
  +    public static Map createParameters( GoalDescriptor goalDescriptor, MavenProject 
project )
  +    {
  +        List parameters = goalDescriptor.getParameters();
  +
  +        int size = parameters.size();
  +
  +        Map map = new HashMap();
  +
  +        for ( int i = 0; i < size; i++ )
  +        {
  +            ParameterDescriptor c = (ParameterDescriptor) parameters.get( i );
  +
  +            String key = c.getName();
  +
  +            String expression = c.getExpression();
  +
  +            Object value = OgnlProjectValueExtractor.evaluate( expression, project 
);
  +
  +            map.put( key, value );
  +        }
  +
  +        return map;
       }
   
       // ----------------------------------------------------------------------
  
  
  
  1.5       +7 -15     
maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/FieldPluginConfigurator.java
  
  Index: FieldPluginConfigurator.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/FieldPluginConfigurator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FieldPluginConfigurator.java      21 Mar 2004 00:33:17 -0000      1.4
  +++ FieldPluginConfigurator.java      7 May 2004 23:46:51 -0000       1.5
  @@ -16,11 +16,9 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.plugin.descriptor.ParameterDescriptor;
  -import org.apache.maven.project.MavenProject;
  -
   import java.lang.reflect.Field;
  -import java.util.List;
  +import java.util.Iterator;
  +import java.util.Map;
   
   /**
    *
  @@ -31,22 +29,16 @@
    */
   public class FieldPluginConfigurator
   {
  -    public Object configure( Object plugin, List parameters, MavenProject project )
  +    public Object configure( Object plugin, Map parameters )
           throws PluginConfigurationException
       {
           Class pluginClass = plugin.getClass();
   
  -        int size = parameters.size();
  -
  -        for ( int i = 0; i < size; i++ )
  +        for ( Iterator iterator = parameters.keySet().iterator(); 
iterator.hasNext(); )
           {
  -            ParameterDescriptor c = (ParameterDescriptor) parameters.get( i );
  -
  -            String fieldName = c.getName();
  -
  -            String expression = c.getExpression();
  +            String fieldName = (String) iterator.next();
   
  -            Object value = OgnlProjectValueExtractor.evaluate( expression, project 
);
  +            Object value = parameters.get( fieldName );
   
               try
               {
  
  
  
  1.7       +4 -7      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/PlexusPluginManager.java
  
  Index: PlexusPluginManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/PlexusPluginManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PlexusPluginManager.java  4 Apr 2004 17:23:44 -0000       1.6
  +++ PlexusPluginManager.java  7 May 2004 23:46:51 -0000       1.7
  @@ -52,15 +52,12 @@
       {
           try
           {
  -            String id = request.getPluginDescriptor().getId();
  -
  -            Object plugin = container.lookup( Plugin.ROLE, id );
  +            Object plugin = container.lookup( Plugin.ROLE, (String) 
request.getContextValue( "id" ) );
   
               request.setPlugin( plugin );
   
  -            String mode = request.getPluginDescriptor().getMode();
  -
  -            PluginExecutor pluginExecutor = (PluginExecutor) container.lookup( 
PluginExecutor.ROLE, mode );
  +            PluginExecutor pluginExecutor =
  +                (PluginExecutor) container.lookup( PluginExecutor.ROLE, (String) 
request.getContextValue( "mode" ) );
   
               pluginExecutor.execute( request, response );
           }
  
  
  
  1.5       +8 -10     
maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/SetterPluginConfigurator.java
  
  Index: SetterPluginConfigurator.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/SetterPluginConfigurator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SetterPluginConfigurator.java     21 Mar 2004 00:33:17 -0000      1.4
  +++ SetterPluginConfigurator.java     7 May 2004 23:46:51 -0000       1.5
  @@ -21,6 +21,8 @@
   
   import java.lang.reflect.Method;
   import java.util.List;
  +import java.util.Map;
  +import java.util.Iterator;
   
   /**
    *
  @@ -31,22 +33,18 @@
    */
   public class SetterPluginConfigurator
   {
  -    public Object configure( Object plugin, List parameters, MavenProject project )
  +    public Object configure( Object plugin, Map parameters )
           throws PluginConfigurationException
       {
           Class pluginClass = plugin.getClass();
   
  -        int size = parameters.size();
  -
  -        for ( int i = 0; i < size; i++ )
  +        for ( Iterator iterator = parameters.keySet().iterator(); 
iterator.hasNext(); )
           {
  -            ParameterDescriptor c = (ParameterDescriptor) parameters.get( i );
  -
  -            String methodName = "set" + capitalise( c.getName() );
  +            String key = (String) iterator.next();
   
  -            String expression = c.getExpression();
  +            Object value = parameters.get( key);
   
  -            Object value = OgnlProjectValueExtractor.evaluate( expression, project 
);
  +            String methodName = "set" + capitalise( key );
   
               try
               {
  
  
  
  1.3       +5 -8      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/executor/FieldPluginExecutor.java
  
  Index: FieldPluginExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/executor/FieldPluginExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FieldPluginExecutor.java  21 Mar 2004 00:33:17 -0000      1.2
  +++ FieldPluginExecutor.java  7 May 2004 23:46:51 -0000       1.3
  @@ -18,12 +18,11 @@
   
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  -import org.apache.maven.plugin.plexus.PluginConfigurationException;
   import org.apache.maven.plugin.plexus.FieldPluginConfigurator;
  +import org.apache.maven.plugin.plexus.PluginConfigurationException;
   
  -import java.util.List;
  -import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Method;
   
   /**
    *
  @@ -44,15 +43,13 @@
   
       public void execute( PluginExecutionRequest request, PluginExecutionResponse 
response )
       {
  -        List parameters = request.getGoalDescriptor().getParameters();
  -
           Object plugin = request.getPlugin();
   
  -        if ( parameters != null )
  +        if ( request.getParameters() != null )
           {
               try
               {
  -                plugin = fieldPluginConfigurator.configure( plugin, parameters, 
request.getProject() );
  +                plugin = fieldPluginConfigurator.configure( plugin, 
request.getParameters() );
               }
               catch ( PluginConfigurationException e )
               {
  
  
  
  1.3       +1 -22     
maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/executor/IntegratedPluginExecutor.java
  
  Index: IntegratedPluginExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/executor/IntegratedPluginExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IntegratedPluginExecutor.java     21 Mar 2004 00:33:17 -0000      1.2
  +++ IntegratedPluginExecutor.java     7 May 2004 23:46:51 -0000       1.3
  @@ -38,27 +38,6 @@
   {
       public void execute( PluginExecutionRequest request, PluginExecutionResponse 
response )
       {
  -        List parameters = request.getGoalDescriptor().getParameters();
  -
  -        int size = parameters.size();
  -
  -        Map map = new HashMap();
  -
  -        for ( int i = 0; i < size; i++ )
  -        {
  -            ParameterDescriptor c = (ParameterDescriptor) parameters.get( i );
  -
  -            String key = c.getName();
  -
  -            String expression = c.getExpression();
  -
  -            Object value = OgnlProjectValueExtractor.evaluate( expression, 
request.getProject() );
  -
  -            map.put( key, value );
  -        }
  -
  -        request.setParameters( map );
  -
           try
           {
               ((Plugin) request.getPlugin()).execute( request, response );
  
  
  
  1.3       +6 -9      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/executor/SetterPluginExecutor.java
  
  Index: SetterPluginExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/plexus/executor/SetterPluginExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SetterPluginExecutor.java 21 Mar 2004 00:33:17 -0000      1.2
  +++ SetterPluginExecutor.java 7 May 2004 23:46:51 -0000       1.3
  @@ -16,14 +16,13 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.plugin.plexus.SetterPluginConfigurator;
  -import org.apache.maven.plugin.plexus.PluginConfigurationException;
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  +import org.apache.maven.plugin.plexus.PluginConfigurationException;
  +import org.apache.maven.plugin.plexus.SetterPluginConfigurator;
   
  -import java.util.List;
  -import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Method;
   
   /**
    *
  @@ -44,15 +43,13 @@
   
       public void execute( PluginExecutionRequest request, PluginExecutionResponse 
response )
       {
  -        List parameters = request.getGoalDescriptor().getParameters();
  -
           Object plugin = request.getPlugin();
   
  -        if ( parameters != null )
  +        if ( request.getParameters() != null )
           {
               try
               {
  -                plugin = setterPluginConfigurator.configure( plugin, parameters, 
request.getProject() );
  +                plugin = setterPluginConfigurator.configure( plugin, 
request.getParameters() );
               }
               catch ( PluginConfigurationException e )
               {
  
  
  
  1.4       +6 -3      
maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginConfiguratorTest.java
  
  Index: PluginConfiguratorTest.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginConfiguratorTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PluginConfiguratorTest.java       21 Mar 2004 00:33:18 -0000      1.3
  +++ PluginConfiguratorTest.java       7 May 2004 23:46:51 -0000       1.4
  @@ -21,9 +21,12 @@
   import org.apache.maven.plugin.descriptor.PluginDescriptor;
   import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
   import org.apache.maven.plugin.plexus.FieldPluginConfigurator;
  +import org.apache.maven.plugin.manager.DefaultPluginManagerManager;
   import org.apache.maven.project.MavenProject;
  +import org.apache.maven.lifecycle.MavenLifecycleContext;
   
   import java.util.Properties;
  +import java.util.Map;
   
   /**
    *
  @@ -82,9 +85,9 @@
   
           GoalDescriptor gd = (GoalDescriptor) pd.getGoals().get( 0 );
   
  -        plugin = (MockPlugin) pc.configure( plugin, gd.getParameters(), project );
  -
  +        Map parameters = DefaultPluginManagerManager.createParameters( gd, project 
);
   
  +        plugin = (MockPlugin) pc.configure( plugin, parameters);
       }
   
       class MockPlugin
  
  
  
  1.6       +1 -21     
maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginTest.java
  
  Index: PluginTest.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PluginTest.java   16 Apr 2004 13:56:09 -0000      1.5
  +++ PluginTest.java   7 May 2004 23:46:51 -0000       1.6
  @@ -85,26 +85,6 @@
           assertEquals( "bar", integratedPlugin.getFoo() );
       }
   
  -    public void testSingletonPlugin()
  -        throws Exception
  -    {
  -        registerPlugin( "singleton-plugin.xml" );
  -
  -        MavenCore maven = (MavenCore) lookup( MavenCore.ROLE );
  -
  -        maven.execute( new File( System.getProperty( "user.dir"), "project.xml" ), 
"singleton-execute" );
  -
  -        SingletonPlugin singletonPlugin = (SingletonPlugin) getContainer().lookup( 
Plugin.ROLE, "singleton-plugin" );
  -
  -        assertTrue( singletonPlugin.hasExecuted() );
  -
  -        assertEquals( "Maven", singletonPlugin.getName() );
  -
  -        assertEquals( "maven-core", singletonPlugin.getArtifactId() );
  -
  -        assertEquals( "bar", singletonPlugin.getFoo() );
  -    }
  -
       public void testSetterPlugin()
           throws Exception
       {
  
  
  

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

Reply via email to