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-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags MetadataTag.java
Date Thu, 14 Apr 2005 03:27:35 GMT
brett       2005/04/13 20:27:35

  Modified:    maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java MavenMojoDescriptor.java
                        PluginParameterExpressionEvaluator.java
               maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly
                        JellyHarnessGenerator.java
               maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator
                        PluginDescriptorGenerator.java
               maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor
                        MojoDescriptor.java PluginDescriptorBuilder.java
               maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags
                        MetadataTag.java
  Log:
  convert #component expressions to <requirements/>
  
  Revision  Changes    Path
  1.79      +11 -8     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.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- DefaultPluginManager.java	13 Apr 2005 18:44:13 -0000	1.78
  +++ DefaultPluginManager.java	14 Apr 2005 03:27:35 -0000	1.79
  @@ -392,14 +392,18 @@
                   configuration = new XmlPlexusConfiguration( dom );
               }
   
  -            Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration,
session );
  -
               if ( newMojoTechnique )
               {
  +                Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration,
session );
  +
                   populatePluginFields( plugin, configuration, map );
               }
               else
               {
  +                getLogger().warn( "WARNING: The mojo " + mojoDescriptor.getId() + " is
using the OLD API" );
  +
  +                Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration,
session );
  +
                   request = createPluginRequest( configuration, map );
               }
   
  @@ -684,12 +688,11 @@
       public void initialize()
       {
           // TODO: configure this from bootstrap or scan lib
  -        artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact",
"maven-model",
  -                                                              "maven-settings", "maven-monitor",
"maven-plugin-api",
  -                                                              "maven-plugin-descriptor",
"plexus-container-default",
  -                                                              "plexus-artifact-container",
"wagon-provider-api",
  -                                                              "classworlds",
  -                                                              "maven-plugin" /* Just re-added
until all plugins are switched over...*/} );
  +        artifactFilter =
  +            new ExclusionSetFilter(
  +                new String[]{"maven-core", "maven-artifact", "maven-model", "maven-settings",
"maven-monitor",
  +                             "maven-plugin-api", "maven-plugin-descriptor", "plexus-container-default",
  +                             "plexus-artifact-container", "wagon-provider-api", "classworlds",
"maven-plugin" /* Just re-added until all plugins are switched over...*/} );
       }
   
       // ----------------------------------------------------------------------
  
  
  
  1.6       +6 -6      maven-components/maven-core/src/main/java/org/apache/maven/plugin/MavenMojoDescriptor.java
  
  Index: MavenMojoDescriptor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/MavenMojoDescriptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MavenMojoDescriptor.java	23 Mar 2005 06:52:52 -0000	1.5
  +++ MavenMojoDescriptor.java	14 Apr 2005 03:27:35 -0000	1.6
  @@ -51,11 +51,6 @@
           return mojoDescriptor.getImplementation();
       }
   
  -    public List getPrereqs()
  -    {
  -        return mojoDescriptor.getPrereqs();
  -    }
  -    
       public String getComponentFactory()
       {
           return mojoDescriptor.getLanguage();
  @@ -75,4 +70,9 @@
       {
           return DefaultPluginManager.MAVEN_PLUGIN;
       }
  +
  +    public List getRequirements()
  +    {
  +        return mojoDescriptor.getRequirements();
  +    }
   }
  
  
  
  1.13      +4 -1      maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
  
  Index: PluginParameterExpressionEvaluator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PluginParameterExpressionEvaluator.java	4 Apr 2005 03:48:01 -0000	1.12
  +++ PluginParameterExpressionEvaluator.java	14 Apr 2005 03:27:35 -0000	1.13
  @@ -40,6 +40,9 @@
           }
           if ( expression.startsWith( "#component" ) )
           {
  +            context.getLog().warn( "WARNING: plugin is using deprecated expression " +
expression );
  +
  +            // TODO: deprecated... and can remove the lookup method in context afterwards
               String role = expression.substring( 11 );
   
               try
  
  
  
  1.4       +0 -21     maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java
  
  Index: JellyHarnessGenerator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JellyHarnessGenerator.java	13 Apr 2005 11:34:09 -0000	1.3
  +++ JellyHarnessGenerator.java	14 Apr 2005 03:27:35 -0000	1.4
  @@ -214,27 +214,6 @@
   
           w.addAttribute( "name", id + ":" + mojoDescriptor.getGoal() );
   
  -        List goalPrereqs = mojoDescriptor.getPrereqs();
  -
  -        if ( goalPrereqs.size() > 0 )
  -        {
  -            StringBuffer prereqs = new StringBuffer();
  -
  -            for ( int j = 0; j < goalPrereqs.size(); j++ )
  -            {
  -                String prereq = (String) goalPrereqs.get( j );
  -
  -                prereqs.append( prereq );
  -
  -                if ( j < goalPrereqs.size() - 1 )
  -                {
  -                    prereqs.append( "," );
  -                }
  -            }
  -
  -            w.addAttribute( "prereqs", prereqs.toString() );
  -        }
  -
           if ( mojoDescriptor.getDescription() != null )
           {
               w.addAttribute( "description", mojoDescriptor.getDescription() );
  
  
  
  1.8       +26 -12    maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
  
  Index: PluginDescriptorGenerator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PluginDescriptorGenerator.java	13 Apr 2005 11:34:09 -0000	1.7
  +++ PluginDescriptorGenerator.java	14 Apr 2005 03:27:35 -0000	1.8
  @@ -25,6 +25,8 @@
   
   import java.io.File;
   import java.io.FileWriter;
  +import java.util.ArrayList;
  +import java.util.Collection;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Set;
  @@ -159,6 +161,7 @@
   
           w.startElement( "parameters" );
   
  +        Collection requirements = new ArrayList();
           for ( int j = 0; j < parameters.size(); j++ )
           {
               Parameter parameter = (Parameter) parameters.get( j );
  @@ -169,11 +172,18 @@
   
               element( w, "type", parameter.getType() );
   
  -            element( w, "required", Boolean.toString( parameter.isRequired() ) );
  -
               element( w, "validator", parameter.getValidator() );
   
  -            element( w, "expression", parameter.getExpression() );
  +            if ( parameter.getExpression().startsWith( "#component" ) )
  +            {
  +                requirements.add( parameter );
  +            }
  +            else
  +            {
  +                element( w, "required", Boolean.toString( parameter.isRequired() ) );
  +
  +                element( w, "expression", parameter.getExpression() );
  +            }
   
               element( w, "description", parameter.getDescription() );
   
  @@ -185,20 +195,24 @@
           w.endElement();
   
           // ----------------------------------------------------------------------
  -        // Prereqs
  +        // Requirements
           // ----------------------------------------------------------------------
   
  -        // TODO: remove
  -
  -        List prereqs = mojoDescriptor.getPrereqs();
  -
  -        if ( prereqs != null && prereqs.size() > 0 )
  +        if ( !requirements.isEmpty() )
           {
  -            w.startElement( "prereqs" );
  +            w.startElement( "requirements" );
   
  -            for ( int j = 0; j < prereqs.size(); j++ )
  +            for ( Iterator i = requirements.iterator(); i.hasNext(); )
               {
  -                element( w, "prereq", (String) prereqs.get( j ) );
  +                Parameter requirement = (Parameter) i.next();
  +
  +                w.startElement( "requirement" );
  +
  +                element( w, "role", requirement.getExpression().substring( 11 ) );
  +
  +                element( w, "field-name", requirement.getName() );
  +
  +                w.endElement();
               }
   
               w.endElement();
  
  
  
  1.2       +24 -20    maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
  
  Index: MojoDescriptor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MojoDescriptor.java	13 Apr 2005 05:08:29 -0000	1.1
  +++ MojoDescriptor.java	14 Apr 2005 03:27:35 -0000	1.2
  @@ -16,11 +16,19 @@
    * limitations under the License.
    */
   
  +import org.codehaus.plexus.component.repository.ComponentRequirement;
  +
  +import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   
  +/**
  + * The bean containing the mojo descriptor.
  + *
  + * @todo is there a need for the delegation of MavenMojoDescriptor to this? Why not just
extend ComponentDescriptor here?
  + */
   public class MojoDescriptor
       implements Cloneable
   {
  @@ -48,12 +56,12 @@
   
       private String phase;
   
  +    private List requirements;
  +
       // ----------------------------------------------------------------------
       //
       // ----------------------------------------------------------------------
   
  -    private List prereqs;
  -
       private String requiresDependencyResolution = null;
   
       private boolean requiresProject = true;
  @@ -64,11 +72,6 @@
       //
       // ----------------------------------------------------------------------
   
  -    public String getRole()
  -    {
  -        return "org.apache.maven.plugin.Plugin";
  -    }
  -
       public String getImplementation()
       {
           return implementation;
  @@ -169,29 +172,25 @@
           this.requiresProject = requiresProject;
       }
   
  -    public boolean requiresProject()
  +    public boolean isRequiresProject()
       {
           return requiresProject;
       }
   
  -    // ----------------------------------------------------------------------
  -    // Prereqs
  -    // ----------------------------------------------------------------------
  -
  -    public List getPrereqs()
  +    public void setRequirements( List requirements )
       {
  -        return prereqs;
  +        this.requirements = requirements;
       }
   
  -    public void setPrereqs( List prereqs )
  +    public List getRequirements()
       {
  -        this.prereqs = prereqs;
  +        if ( requirements == null )
  +        {
  +            requirements = new ArrayList();
  +        }
  +        return requirements;
       }
   
  -    // ----------------------------------------------------------------------
  -    //
  -    // ----------------------------------------------------------------------
  -
       public String getPhase()
       {
           return phase;
  @@ -226,4 +225,9 @@
       {
           this.executionStrategy = executionStrategy;
       }
  +
  +    public void addRequirement( ComponentRequirement cr )
  +    {
  +        getRequirements().add( cr );
  +    }
   }
  
  
  
  1.3       +17 -10    maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
  
  Index: PluginDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PluginDescriptorBuilder.java	13 Apr 2005 11:34:09 -0000	1.2
  +++ PluginDescriptorBuilder.java	14 Apr 2005 03:27:35 -0000	1.3
  @@ -1,5 +1,6 @@
   package org.apache.maven.plugin.descriptor;
   
  +import org.codehaus.plexus.component.repository.ComponentRequirement;
   import org.codehaus.plexus.configuration.PlexusConfiguration;
   import org.codehaus.plexus.configuration.PlexusConfigurationException;
   import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
  @@ -155,22 +156,28 @@
   
           mojo.setParameters( parameters );
   
  +        // TODO: this should not need to be handed off...
  +
           // ----------------------------------------------------------------------
  -        // Prereqs
  +        // Requirements
           // ----------------------------------------------------------------------
   
  -        PlexusConfiguration[] prereqConfigurations = c.getChild( "prereqs" ).getChildren(
"prereq" );
  -
  -        List prereqs = new ArrayList();
  +        PlexusConfiguration[] requirements = c.getChild( "requirements" ).getChildren(
"requirement" );
   
  -        for ( int i = 0; i < prereqConfigurations.length; i++ )
  +        for ( int i = 0; i < requirements.length; i++ )
           {
  -            PlexusConfiguration d = prereqConfigurations[i];
  +            PlexusConfiguration requirement = requirements[i];
   
  -            prereqs.add( d.getValue() );
  -        }
  +            ComponentRequirement cr = new ComponentRequirement();
  +
  +            cr.setRole( requirement.getChild( "role" ).getValue() );
   
  -        mojo.setPrereqs( prereqs );
  +            cr.setRoleHint( requirement.getChild( "role-hint" ).getValue() );
  +
  +            cr.setFieldName( requirement.getChild( "field-name" ).getValue() );
  +
  +            mojo.addRequirement( cr );
  +        }
   
           return mojo;
       }
  
  
  
  1.7       +2 -0      maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags/MetadataTag.java
  
  Index: MetadataTag.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags/MetadataTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MetadataTag.java	5 Apr 2005 08:17:28 -0000	1.6
  +++ MetadataTag.java	14 Apr 2005 03:27:35 -0000	1.7
  @@ -103,6 +103,8 @@
           descriptor.setRequiresDependencyResolution( requiresDependencyResolution );
           descriptor.setRequiresProject( requiresProject );
   
  +        // TODO: component requirements
  +
           String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
                                                           getExpressionEvaluator() );
   
  
  
  

Mime
View raw message