maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject cvs commit: maven-components/maven-plugin-loaders/maven-marmalade-loader/src/main/java/org/apache/maven/plugin/loader/marmalade MarmaladeScriptMojo.java
Date Tue, 10 Aug 2004 03:28:56 GMT
jdcasey     2004/08/09 20:28:56

  Modified:    maven-plugin-loaders/maven-marmalade-loader/src/main/java/org/apache/maven/plugin/loader/marmalade/tags
                        MojoTag.java
  Added:       maven-plugin-loaders/maven-marmalade-loader/src/main/java/org/apache/maven/plugin/loader/marmalade
                        MarmaladeScriptMojo.java
  Log:
  o Added a mojo wrapper which executes a marmalade script
  o Modified the mojo tag to create a mojo/plexus component when not in describeOnly mode...for
execution.
  
  Revision  Changes    Path
  1.2       +27 -15    maven-components/maven-plugin-loaders/maven-marmalade-loader/src/main/java/org/apache/maven/plugin/loader/marmalade/tags/MojoTag.java
  
  Index: MojoTag.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-loaders/maven-marmalade-loader/src/main/java/org/apache/maven/plugin/loader/marmalade/tags/MojoTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MojoTag.java	8 Aug 2004 05:11:13 -0000	1.1
  +++ MojoTag.java	10 Aug 2004 03:28:56 -0000	1.2
  @@ -6,20 +6,25 @@
   import java.util.Set;
   
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
  +import org.apache.maven.plugin.loader.marmalade.MarmaladeScriptMojo;
   import org.codehaus.marmalade.model.AbstractMarmaladeTag;
  +import org.codehaus.marmalade.model.MarmaladeScript;
   import org.codehaus.marmalade.model.MarmaladeTag;
   import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
   import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
  +import org.codehaus.plexus.component.factory.marmalade.PlexusComponentTag;
   
   /**
    * @author jdcasey
    */
  -public class MojoTag extends AbstractMarmaladeTag
  +public class MojoTag extends AbstractMarmaladeTag implements PlexusComponentTag
   {
       private boolean describeOnly = false;
       
       private List dependencies;
       private MojoDescriptor descriptor;
  +    
  +    private MarmaladeScriptMojo mojo; 
   
       protected boolean alwaysProcessChildren(  )
       {
  @@ -30,23 +35,26 @@
           throws MarmaladeExecutionException
       {
           boolean describeOnly = describeOnly();
  -        for (Iterator it = children().iterator(); it.hasNext();) {
  -            MarmaladeTag child = (MarmaladeTag) it.next();
  -            
  -            if(describeOnly && (child instanceof MojoDescriptorTag)) {
  -                MojoDescriptorTag headerTag = (MojoDescriptorTag)child;
  -                child.execute(context);
  -                
  -                this.descriptor = headerTag.getMojoDescriptor();
  -                this.dependencies = headerTag.getDependencies();
  +        if(describeOnly) {
  +            for (Iterator it = children().iterator(); it.hasNext();) {
  +                MarmaladeTag child = (MarmaladeTag) it.next();
                   
  -                // we're done with the description phase.
  -                break;
  -            }
  -            else if(!describeOnly) {
  -                child.execute(context);
  +                if(child instanceof MojoDescriptorTag) {
  +                    MojoDescriptorTag headerTag = (MojoDescriptorTag)child;
  +                    child.execute(context);
  +                    
  +                    this.descriptor = headerTag.getMojoDescriptor();
  +                    this.dependencies = headerTag.getDependencies();
  +                    
  +                    // we're done with the description phase.
  +                    break;
  +                }
               }
           }
  +        else {
  +            MarmaladeScript script = new MarmaladeScript(getTagInfo().getSourceFile(),
this);
  +            this.mojo = new MarmaladeScriptMojo(script);
  +        }
       }
   
       public MojoDescriptor getMojoDescriptor() {
  @@ -64,6 +72,10 @@
       
       public boolean describeOnly() {
           return describeOnly;
  +    }
  +
  +    public Object getComponent() {
  +        return mojo;
       }
       
   }
  
  
  
  1.1                  maven-components/maven-plugin-loaders/maven-marmalade-loader/src/main/java/org/apache/maven/plugin/loader/marmalade/MarmaladeScriptMojo.java
  
  Index: MarmaladeScriptMojo.java
  ===================================================================
  /* Created on Aug 9, 2004 */
  package org.apache.maven.plugin.loader.marmalade;
  
  import org.apache.maven.plugin.AbstractPlugin;
  import org.apache.maven.plugin.PluginExecutionRequest;
  import org.apache.maven.plugin.PluginExecutionResponse;
  import org.codehaus.marmalade.model.MarmaladeScript;
  import org.codehaus.marmalade.runtime.DefaultContext;
  import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
  
  /**
   * @author jdcasey
   */
  public class MarmaladeScriptMojo extends AbstractPlugin {
      
      public static final String REQUEST_VARIABLE = "request";
      public static final String RESPONSE_VARIABLE = "response";
      
      private MarmaladeScript script;
  
      public MarmaladeScriptMojo(MarmaladeScript script) {
          this.script = script;
      }
  
      public void execute(PluginExecutionRequest request,
              PluginExecutionResponse response) throws Exception {
          
          MarmaladeExecutionContext context = new DefaultContext();
          context.setVariable(REQUEST_VARIABLE, request);
          context.setVariable(RESPONSE_VARIABLE, response);
          
          script.execute(context);
      }
  
  }
  
  
  

Mime
View raw message