jvanzyl     2004/05/12 16:38:41

  Modified:    maven-core project.xml
               maven-core/src/main/java/org/apache/maven
                        DefaultMavenCore.java Maven.java MavenCore.java
               maven-core/src/main/java/org/apache/maven/lifecycle
                        DefaultMavenLifecycleManager.java
                        MavenLifecycleContext.java MavenLifecyclePhase.java
               maven-core/src/main/java/org/apache/maven/lifecycle/phase
                        GoalDecorationPhase.java
               maven-core/src/main/java/org/apache/maven/plugin Plugin.java
                        PluginConfigurationException.java
                        PluginExecutionRequest.java
                        PluginExecutionResponse.java
               maven-core/src/main/java/org/apache/maven/plugin/descriptor
                        GoalDescriptor.java ParameterDescriptor.java
                        PluginDescriptor.java PluginDescriptorBuilder.java
               maven-core/src/main/java/org/apache/maven/plugin/discovery
                        MavenPluginDiscoverer.java
               maven-core/src/main/java/org/apache/maven/plugin/manager
                        AbstractPluginManager.java
                        DefaultPluginManager.java
                        OgnlProjectValueExtractor.java PluginManager.java
               maven-core/src/main/java/org/apache/maven/plugin/manager/executor
                        FieldPluginExecutor.java
                        IntegratedPluginExecutor.java PluginExecutor.java
                        SetterPluginExecutor.java
  Added:       maven-core/src/main/java/org/apache/maven/script/taglib
                        AbstractGoalDecoratorTag.java
                        MavenScriptTagLibrary.java MavenTag.java
                        PostGoalTag.java PreGoalTag.java
               maven-core/src/test/java/org/apache/maven/lifecycle/phase
                        GoalDecorationPhaseTest.java
  Log:
  o adding John Casey's patch which adds support for maven.xml processing in
    maven2 using marmlade which is a Jelly replacement.
  
  Revision  Changes    Path
  1.11      +16 -0     maven-components/maven-core/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/project.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- project.xml       8 May 2004 01:28:51 -0000       1.10
  +++ project.xml       12 May 2004 23:38:40 -0000      1.11
  @@ -59,6 +59,22 @@
         <artifactId>ognl</artifactId>
         <version>2.5.1</version>
       </dependency>
  +    <!-- Used to support maven.xml script and goal decorating in general. -->
  +    <dependency>
  +      <groupId>marmalade</groupId>
  +      <artifactId>marmalade-core</artifactId>
  +      <version>0.1</version>
  +    </dependency>
  +    <dependency>
  +      <groupId>marmalade</groupId>
  +      <artifactId>marmalade-el-ognl</artifactId>
  +      <version>0.1</version>
  +    </dependency>
  +    <dependency>
  +      <groupId>tagalog</groupId>
  +      <artifactId>tagalog</artifactId>
  +      <version>0.1</version>
  +    </dependency>
       <!-- This will eventually be removed -->
       <dependency>
         <groupId>plexus</groupId>
  
  
  
  1.4       +5 -6      
maven-components/maven-core/src/main/java/org/apache/maven/DefaultMavenCore.java
  
  Index: DefaultMavenCore.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/DefaultMavenCore.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultMavenCore.java     9 May 2004 23:00:59 -0000       1.3
  +++ DefaultMavenCore.java     12 May 2004 23:38:40 -0000      1.4
  @@ -26,17 +26,17 @@
   import org.apache.maven.project.ProjectBuildingException;
   import org.codehaus.plexus.PlexusConstants;
   import org.codehaus.plexus.PlexusContainer;
  -import org.codehaus.plexus.util.FileUtils;
  -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
   import org.codehaus.plexus.context.Context;
   import org.codehaus.plexus.context.ContextException;
   import org.codehaus.plexus.i18n.I18N;
  +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
  +import org.codehaus.plexus.util.FileUtils;
   
   import java.io.File;
  -import java.util.List;
  -import java.util.Map;
   import java.util.ArrayList;
   import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
   
   public class DefaultMavenCore
       implements MavenCore, Contextualizable
  @@ -106,8 +106,7 @@
   
           try
           {
  -            List files = FileUtils.getFiles(
  -                new File( System.getProperty( "user.dir" ) ), 
"**/project.xml,**/project2.xml", "project.xml,project2.xml" );
  +            List files = FileUtils.getFiles( new File( System.getProperty( 
"user.dir" ) ), "**/project.xml,**/project2.xml", "project.xml,project2.xml" );
   
               for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
               {
  
  
  
  1.14      +4 -4      
maven-components/maven-core/src/main/java/org/apache/maven/Maven.java
  
  Index: Maven.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/Maven.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Maven.java        9 May 2004 23:00:59 -0000       1.13
  +++ Maven.java        12 May 2004 23:38:40 -0000      1.14
  @@ -24,8 +24,8 @@
   import org.codehaus.plexus.embed.Embedder;
   
   import java.io.File;
  -import java.util.Map;
   import java.net.URL;
  +import java.util.Map;
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  @@ -76,7 +76,7 @@
       }
   
       public void execute( File projectFile, String goal )
  -        throws ProjectBuildingException,GoalNotFoundException
  +        throws ProjectBuildingException, GoalNotFoundException
       {
           maven.execute( getProject( projectFile ), goal );
       }
  @@ -92,7 +92,7 @@
       // ----------------------------------------------------------------------
   
       public void executeReactor( String goal )
  -        throws ReactorException,GoalNotFoundException
  +        throws ReactorException, GoalNotFoundException
       {
           maven.executeReactor( goal );
       }
  
  
  
  1.3       +5 -9      
maven-components/maven-core/src/main/java/org/apache/maven/MavenCore.java
  
  Index: MavenCore.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenCore.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MavenCore.java    9 May 2004 23:00:59 -0000       1.2
  +++ MavenCore.java    12 May 2004 23:38:40 -0000      1.3
  @@ -16,20 +16,16 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.plugin.descriptor.PluginDescriptor;
   import org.apache.maven.plugin.descriptor.GoalDescriptor;
  -import org.apache.maven.project.ProjectBuildingException;
  +import org.apache.maven.plugin.descriptor.PluginDescriptor;
   import org.apache.maven.project.MavenProject;
  +import org.apache.maven.project.ProjectBuildingException;
   
   import java.io.File;
  -import java.util.List;
   import java.util.Map;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public interface MavenCore
  @@ -47,14 +43,14 @@
           throws GoalNotFoundException;
   
       void execute( File project, String goal )
  -        throws ProjectBuildingException,GoalNotFoundException;
  +        throws ProjectBuildingException, GoalNotFoundException;
   
       // ----------------------------------------------------------------------
       // Reactor execution
       // ----------------------------------------------------------------------
   
       void executeReactor( String goal )
  -        throws ReactorException,GoalNotFoundException;
  +        throws ReactorException, GoalNotFoundException;
   
       // ----------------------------------------------------------------------
       // Plugin descriptors
  
  
  
  1.3       +3 -4      
maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultMavenLifecycleManager.java
  
  Index: DefaultMavenLifecycleManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultMavenLifecycleManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultMavenLifecycleManager.java 5 Apr 2004 15:55:21 -0000       1.2
  +++ DefaultMavenLifecycleManager.java 12 May 2004 23:38:40 -0000      1.3
  @@ -1,7 +1,7 @@
   package org.apache.maven.lifecycle;
   
  -import java.util.List;
   import java.util.Iterator;
  +import java.util.List;
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  @@ -30,8 +30,7 @@
               }
               catch ( Exception cause )
               {
  -                throw new Exception(
  -                    "Exception occurred during the execution of " + 
phase.getClass().getName() + ".", cause );
  +                throw new Exception( "Exception occurred during the execution of " 
+ phase.getClass().getName() + ".", cause );
               }
           }
       }
  
  
  
  1.6       +15 -2     
maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecycleContext.java
  
  Index: MavenLifecycleContext.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecycleContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MavenLifecycleContext.java        16 Apr 2004 13:56:09 -0000      1.5
  +++ MavenLifecycleContext.java        12 May 2004 23:38:40 -0000      1.6
  @@ -1,7 +1,7 @@
   package org.apache.maven.lifecycle;
   
  -import org.apache.maven.MavenCore;
   import org.apache.maven.project.MavenProject;
  +import org.apache.maven.script.MavenScript;
   import org.codehaus.plexus.PlexusContainer;
   
   /**
  @@ -14,6 +14,8 @@
   
       private MavenProject project;
   
  +    private MavenScript script;
  +
       private String goal;
   
       public MavenLifecycleContext( PlexusContainer container, MavenProject project, 
String goal )
  @@ -44,4 +46,15 @@
       {
           return goal;
       }
  +
  +    public MavenScript getScript()
  +    {
  +        return script;
  +    }
  +
  +    public void setScript( MavenScript script )
  +    {
  +        this.script = script;
  +    }
  +
   }
  
  
  
  1.5       +3 -3      
maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecyclePhase.java
  
  Index: MavenLifecyclePhase.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecyclePhase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MavenLifecyclePhase.java  16 Apr 2004 13:56:09 -0000      1.4
  +++ MavenLifecyclePhase.java  12 May 2004 23:38:40 -0000      1.5
  @@ -1,6 +1,6 @@
   package org.apache.maven.lifecycle;
   
  -import org.apache.maven.MavenCore;
  +
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  @@ -11,5 +11,5 @@
       String ROLE = MavenLifecyclePhase.class.getName();
   
       void execute( MavenLifecycleContext context )
  -        throws Exception;   
  +        throws Exception;
   }
  
  
  
  1.2       +45 -1     
maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalDecorationPhase.java
  
  Index: GoalDecorationPhase.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalDecorationPhase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GoalDecorationPhase.java  8 May 2004 12:57:46 -0000       1.1
  +++ GoalDecorationPhase.java  12 May 2004 23:38:40 -0000      1.2
  @@ -2,16 +2,60 @@
   
   import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
   import org.apache.maven.lifecycle.MavenLifecycleContext;
  +import org.apache.maven.project.MavenProject;
  +import org.apache.maven.script.MavenScript;
  +import org.apache.maven.script.taglib.MavenScriptTagLibrary;
  +import org.codehaus.marmalade.MarmaladeFBTaglibResolver;
  +import org.codehaus.tagalog.ParserConfiguration;
  +import org.codehaus.tagalog.TagalogParser;
  +import org.codehaus.tagalog.xpp.TagalogXmlPullParserFactory;
  +
  +import java.io.BufferedInputStream;
  +import java.io.File;
  +import java.io.FileInputStream;
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  + * @author <a href="mailto:[EMAIL PROTECTED]">John Casey</a>
    * @version $Id$
    */
   public class GoalDecorationPhase
       extends AbstractMavenLifecyclePhase
   {
  +    public static final String MAVEN_XML_DEFAULT_NAMESPACE = "mavenxml";
  +
  +    public static final String MAVEN_SCRIPT = "maven.xml";
  +
       public void execute( MavenLifecycleContext context )
           throws Exception
       {
  +        MavenProject project = context.getProject();
  +
  +        File pom = project.getFile();
  +
  +        File dir = pom.getParentFile();
  +
  +        File scriptFile = new File( dir, MAVEN_SCRIPT );
  +
  +        if ( scriptFile.exists() )
  +        {
  +            ParserConfiguration configuration = new ParserConfiguration( new 
MarmaladeFBTaglibResolver( "" ) );
  +
  +            configuration.setDefaultNamespace( MAVEN_XML_DEFAULT_NAMESPACE );
  +
  +            configuration.addTagLibrary( MAVEN_XML_DEFAULT_NAMESPACE, new 
MavenScriptTagLibrary() );
  +
  +            BufferedInputStream stream = new BufferedInputStream( new 
FileInputStream( scriptFile ) );
  +
  +            TagalogXmlPullParserFactory factory = new TagalogXmlPullParserFactory( 
configuration );
  +
  +            TagalogParser parser = factory.createParser( stream );
  +
  +            MavenScript script = (MavenScript) parser.parse();
  +
  +            context.setScript( script );
  +
  +            stream.close();
  +        }
       }
   }
  
  
  
  1.5       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/Plugin.java
  
  Index: Plugin.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/Plugin.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Plugin.java       8 May 2004 00:17:42 -0000       1.4
  +++ Plugin.java       12 May 2004 23:38:40 -0000      1.5
  @@ -17,10 +17,7 @@
    */
   
   /**
  - *
  - * 
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public interface Plugin
  
  
  
  1.2       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java
  
  Index: PluginConfigurationException.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PluginConfigurationException.java 8 May 2004 00:50:35 -0000       1.1
  +++ PluginConfigurationException.java 12 May 2004 23:38:40 -0000      1.2
  @@ -17,10 +17,7 @@
    */
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class PluginConfigurationException
  
  
  
  1.6       +1 -4      
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PluginExecutionRequest.java       7 May 2004 23:46:51 -0000       1.5
  +++ PluginExecutionRequest.java       12 May 2004 23:38:40 -0000      1.6
  @@ -20,10 +20,7 @@
   import java.util.Map;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class PluginExecutionRequest
  
  
  
  1.5       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionResponse.java
  
  Index: PluginExecutionResponse.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginExecutionResponse.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PluginExecutionResponse.java      21 Mar 2004 00:33:17 -0000      1.4
  +++ PluginExecutionResponse.java      12 May 2004 23:38:40 -0000      1.5
  @@ -17,10 +17,7 @@
    */
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class PluginExecutionResponse
  
  
  
  1.9       +1 -5      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/GoalDescriptor.java
  
  Index: GoalDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/GoalDescriptor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- GoalDescriptor.java       9 May 2004 23:00:59 -0000       1.8
  +++ GoalDescriptor.java       12 May 2004 23:38:40 -0000      1.9
  @@ -16,14 +16,10 @@
    * limitations under the License.
    */
   
  -import java.util.ArrayList;
   import java.util.List;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class GoalDescriptor
  
  
  
  1.4       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/ParameterDescriptor.java
  
  Index: ParameterDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/ParameterDescriptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ParameterDescriptor.java  9 May 2004 23:00:59 -0000       1.3
  +++ ParameterDescriptor.java  12 May 2004 23:38:40 -0000      1.4
  @@ -17,10 +17,7 @@
    */
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class ParameterDescriptor
  
  
  
  1.7       +0 -2      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
  
  Index: PluginDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PluginDescriptor.java     9 May 2004 23:00:59 -0000       1.6
  +++ PluginDescriptor.java     12 May 2004 23:38:40 -0000      1.7
  @@ -17,10 +17,8 @@
    */
   
   import org.codehaus.plexus.component.repository.ComponentDescriptor;
  -import org.apache.maven.plugin.Plugin;
   
   import java.util.List;
  -import java.util.ArrayList;
   
   public class PluginDescriptor
       extends ComponentDescriptor
  
  
  
  1.5       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
  
  Index: PluginDescriptorBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PluginDescriptorBuilder.java      8 May 2004 02:23:48 -0000       1.4
  +++ PluginDescriptorBuilder.java      12 May 2004 23:38:40 -0000      1.5
  @@ -23,10 +23,7 @@
   import java.io.StringReader;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class PluginDescriptorBuilder
  
  
  
  1.2       +2 -5      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/discovery/MavenPluginDiscoverer.java
  
  Index: MavenPluginDiscoverer.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/discovery/MavenPluginDiscoverer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenPluginDiscoverer.java        8 May 2004 00:56:25 -0000       1.1
  +++ MavenPluginDiscoverer.java        12 May 2004 23:38:40 -0000      1.2
  @@ -16,8 +16,8 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
   import org.apache.maven.plugin.descriptor.PluginDescriptor;
  +import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
   import org.codehaus.plexus.component.discovery.AbstractComponentDiscoverer;
   import org.codehaus.plexus.configuration.PlexusConfiguration;
   
  @@ -25,10 +25,7 @@
   import java.util.List;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class MavenPluginDiscoverer
  
  
  
  1.6       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/AbstractPluginManager.java
  
  Index: AbstractPluginManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/AbstractPluginManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractPluginManager.java        8 May 2004 20:48:00 -0000       1.5
  +++ AbstractPluginManager.java        12 May 2004 23:38:40 -0000      1.6
  @@ -20,10 +20,7 @@
   import java.util.List;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public abstract class AbstractPluginManager
  
  
  
  1.3       +74 -7     
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/DefaultPluginManager.java
  
  Index: DefaultPluginManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/DefaultPluginManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultPluginManager.java 8 May 2004 23:34:18 -0000       1.2
  +++ DefaultPluginManager.java 12 May 2004 23:38:40 -0000      1.3
  @@ -26,6 +26,7 @@
   import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
   import org.apache.maven.plugin.manager.executor.PluginExecutor;
   import org.apache.maven.project.MavenProject;
  +import org.apache.maven.script.GoalDecorator;
   import org.codehaus.plexus.PlexusConstants;
   import org.codehaus.plexus.PlexusContainer;
   import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
  @@ -43,6 +44,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Stack;
   
   public class DefaultPluginManager
       extends AbstractLogEnabled
  @@ -89,9 +91,36 @@
   
           int goalIndex = goals.indexOf( goalToAttain );
   
  -        for ( int j = 0; j <= goalIndex; j++ )
  +        List goalList = goals.subList( 0, goalIndex + 1 );
  +
  +        Stack execStack = new Stack();
  +
  +        for ( Iterator it = goalList.iterator(); it.hasNext(); )
  +        {
  +
  +            execStack.push( it.next() );
  +        }
  +
  +        attainGoalStack( context, execStack, response );
  +
  +        return response;
  +    }
  +
  +    /**
  +     * The presumption is that a goal and all of its prerequisites are considered 
to be an atomic
  +     * whole. Therefore, execution should proceed in the manner:
  +     * preGoals, prereqs, goal, postGoals
  +     *
  +     * @param goals    The stack of goals to execute, in reverse-dependency 
ordering. This allows
  +     *                 us easier access to the pregoals before we execute the 
prerequisites.
  +     * @param response The execution response to send through the pre-goal, 
post-goal, prereq, and
  +     *                 actual goal executions.
  +     */
  +    private void attainGoalStack( MavenLifecycleContext context, Stack goals, 
PluginExecutionResponse response )
  +    {
  +        if ( !goals.isEmpty() )
           {
  -            String goalName = (String) goals.get( j );
  +            String goalName = (String) goals.pop();
   
               context.setGoal( goalName );
   
  @@ -109,15 +138,53 @@
   
               request.addContextValue( "mode", getPluginDescriptor( goal ).getMode() 
);
   
  -            attainGoal( request, response );
  +            if ( context.getScript() != null )
  +            {
  +                List preGoals = context.getScript().getPreGoals( goal );
  +
  +                for ( Iterator it = preGoals.iterator(); it.hasNext(); )
  +                {
  +                    GoalDecorator preGoal = (GoalDecorator) it.next();
  +
  +                    preGoal.execute( request, response );
  +
  +                    if ( response.exceptionOccurred() )
  +                    {
  +                        break;
  +                    }
  +                }
  +            }
   
  -            if ( response.exceptionOccurred() )
  +            if ( !response.exceptionOccurred() )
               {
  -                return response;
  +                attainGoalStack( context, goals, response );
               }
  -        }
   
  -        return response;
  +            if ( !response.exceptionOccurred() )
  +            {
  +                attainGoal( request, response );
  +            }
  +
  +            if ( !response.exceptionOccurred() )
  +            {
  +                if ( context.getScript() != null )
  +                {
  +                    List postGoals = context.getScript().getPostGoals( goal );
  +
  +                    for ( Iterator it = postGoals.iterator(); it.hasNext(); )
  +                    {
  +                        GoalDecorator postGoal = (GoalDecorator) it.next();
  +
  +                        postGoal.execute( request, response );
  +
  +                        if ( response.exceptionOccurred() )
  +                        {
  +                            break;
  +                        }
  +                    }
  +                }
  +            }
  +        }
       }
   
       public void attainGoal( PluginExecutionRequest request, PluginExecutionResponse 
response )
  
  
  
  1.2       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/OgnlProjectValueExtractor.java
  
  Index: OgnlProjectValueExtractor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/OgnlProjectValueExtractor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OgnlProjectValueExtractor.java    8 May 2004 00:50:35 -0000       1.1
  +++ OgnlProjectValueExtractor.java    12 May 2004 23:38:40 -0000      1.2
  @@ -21,10 +21,7 @@
   import org.apache.maven.project.MavenProject;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class OgnlProjectValueExtractor
  
  
  
  1.9       +1 -4      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/PluginManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PluginManager.java        8 May 2004 21:11:17 -0000       1.8
  +++ PluginManager.java        12 May 2004 23:38:40 -0000      1.9
  @@ -24,10 +24,7 @@
   import java.util.Map;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public interface PluginManager
  
  
  
  1.3       +3 -8      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/FieldPluginExecutor.java
  
  Index: FieldPluginExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/FieldPluginExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FieldPluginExecutor.java  8 May 2004 23:34:18 -0000       1.2
  +++ FieldPluginExecutor.java  12 May 2004 23:38:40 -0000      1.3
  @@ -16,10 +16,9 @@
    * limitations under the License.
    */
   
  +import org.apache.maven.plugin.PluginConfigurationException;
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  -import org.apache.maven.plugin.PluginConfigurationException;
  -import org.apache.maven.plugin.PluginConfigurationException;
   
   import java.lang.reflect.Field;
   import java.lang.reflect.InvocationTargetException;
  @@ -28,10 +27,7 @@
   import java.util.Map;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class FieldPluginExecutor
  @@ -101,8 +97,7 @@
               }
               catch ( Exception e )
               {
  -                throw new PluginConfigurationException(
  -                    "Error setting value of field " + fieldName + " with " + value 
+ ".", e );
  +                throw new PluginConfigurationException( "Error setting value of 
field " + fieldName + " with " + value + ".", e );
               }
           }
   
  
  
  
  1.3       +2 -5      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/IntegratedPluginExecutor.java
  
  Index: IntegratedPluginExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/IntegratedPluginExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IntegratedPluginExecutor.java     8 May 2004 23:26:46 -0000       1.2
  +++ IntegratedPluginExecutor.java     12 May 2004 23:38:40 -0000      1.3
  @@ -21,10 +21,7 @@
   import org.apache.maven.plugin.PluginExecutionResponse;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class IntegratedPluginExecutor
  @@ -34,7 +31,7 @@
       {
           try
           {
  -            ((Plugin) request.getPlugin()).execute( request, response );
  +            ( (Plugin) request.getPlugin() ).execute( request, response );
           }
           catch ( Exception e )
           {
  
  
  
  1.2       +2 -5      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/PluginExecutor.java
  
  Index: PluginExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/PluginExecutor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PluginExecutor.java       8 May 2004 00:50:35 -0000       1.1
  +++ PluginExecutor.java       12 May 2004 23:38:40 -0000      1.2
  @@ -16,14 +16,11 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.plugin.PluginExecutionResponse;
   import org.apache.maven.plugin.PluginExecutionRequest;
  +import org.apache.maven.plugin.PluginExecutionResponse;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public interface PluginExecutor
  
  
  
  1.3       +4 -9      
maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/SetterPluginExecutor.java
  
  Index: SetterPluginExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/manager/executor/SetterPluginExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SetterPluginExecutor.java 8 May 2004 23:34:18 -0000       1.2
  +++ SetterPluginExecutor.java 12 May 2004 23:38:40 -0000      1.3
  @@ -16,10 +16,9 @@
    * limitations under the License.
    */
   
  +import org.apache.maven.plugin.PluginConfigurationException;
   import org.apache.maven.plugin.PluginExecutionRequest;
   import org.apache.maven.plugin.PluginExecutionResponse;
  -import org.apache.maven.plugin.PluginConfigurationException;
  -import org.apache.maven.plugin.PluginConfigurationException;
   
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
  @@ -27,10 +26,7 @@
   import java.util.Map;
   
   /**
  - *
  - *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - *
    * @version $Id$
    */
   public class SetterPluginExecutor
  @@ -89,7 +85,7 @@
           {
               String key = (String) iterator.next();
   
  -            Object value = parameters.get( key);
  +            Object value = parameters.get( key );
   
               String methodName = "set" + capitalise( key );
   
  @@ -101,8 +97,7 @@
               }
               catch ( Exception e )
               {
  -                throw new PluginConfigurationException(
  -                    "Error setting value with method " + methodName + " with " + 
value + ".", e );
  +                throw new PluginConfigurationException( "Error setting value with 
method " + methodName + " with " + value + ".", e );
               }
           }
   
  
  
  
  1.1                  
maven-components/maven-core/src/main/java/org/apache/maven/script/taglib/AbstractGoalDecoratorTag.java
  
  Index: AbstractGoalDecoratorTag.java
  ===================================================================
  /* Created on Apr 9, 2004 */
  package org.apache.maven.script.taglib;
  
  import org.apache.maven.script.DefaultGoalDecorator;
  import org.apache.maven.script.GoalDecorator;
  import org.apache.maven.script.MavenScript;
  import org.codehaus.marmalade.MarmaladeScript;
  import org.codehaus.marmalade.abstractions.AbstractMarmaladeTag;
  import org.codehaus.tagalog.AbstractTag;
  import org.codehaus.tagalog.Attributes;
  import org.codehaus.tagalog.TagException;
  import org.codehaus.tagalog.TagalogParseException;
  
  /**
   * @author jdcasey
   */
  public abstract class AbstractGoalDecoratorTag extends AbstractTag
  {
  
      public static final String NAME_ATTRIBUTE = "name";
  
      private String goalName;
      private MarmaladeScriptAggregator aggregator = new MarmaladeScriptAggregator();
  
      /**
       */
      protected AbstractGoalDecoratorTag()
      {
      }
  
      protected abstract void addDecorator( MavenScript script, GoalDecorator 
decorator );
  
      protected abstract String getDecoratorClass();
  
      public void begin( String element, Attributes attributes )
          throws TagException, TagalogParseException
      {
          this.goalName = attributes.getValue( NAME_ATTRIBUTE );
      }
  
      public Object end( String element ) throws TagException, TagalogParseException
      {
          MavenScript script = (MavenScript) getContext().get( 
MavenScript.PARSE_CTX_KEY );
          addDecorator( script,
                        new DefaultGoalDecorator( goalName,
                                                  new MarmaladeScript( 
getDecoratorClass() + ":" + goalName, aggregator ) ) );
  
          return null;
      }
  
      public boolean recycle()
      {
          this.goalName = null;
          return true;
      }
  
      public void child( Object child ) throws TagException, TagalogParseException
      {
          aggregator.child( child );
      }
  
      public static final class MarmaladeScriptAggregator extends AbstractMarmaladeTag
          {
          MarmaladeScriptAggregator()
          {
          }
      }
  
  }
  
  
  
  1.1                  
maven-components/maven-core/src/main/java/org/apache/maven/script/taglib/MavenScriptTagLibrary.java
  
  Index: MavenScriptTagLibrary.java
  ===================================================================
  /* Created on Apr 9, 2004 */
  package org.apache.maven.script.taglib;
  
  import org.codehaus.marmalade.abstractions.AbstractMarmaladeTagLibrary;
  import org.codehaus.tagalog.AbstractTag;
  import org.codehaus.tagalog.AbstractTagLibrary;
  
  /**
   * @author jdcasey
   */
  public class MavenScriptTagLibrary extends AbstractMarmaladeTagLibrary
  {
  
      /**
       */
      public MavenScriptTagLibrary()
      {
          registerTag( MavenTag.TAG, MavenTag.class );
          registerTag( PreGoalTag.TAG, PreGoalTag.class );
          registerTag( PostGoalTag.TAG, PostGoalTag.class );
      }
  
  }
  
  
  
  1.1                  
maven-components/maven-core/src/main/java/org/apache/maven/script/taglib/MavenTag.java
  
  Index: MavenTag.java
  ===================================================================
  /* Created on Apr 9, 2004 */
  package org.apache.maven.script.taglib;
  
  import org.apache.maven.script.MavenScript;
  import org.codehaus.tagalog.AbstractTag;
  import org.codehaus.tagalog.Attributes;
  import org.codehaus.tagalog.TagException;
  import org.codehaus.tagalog.TagalogParseException;
  
  /**
   * @author jdcasey
   */
  public class MavenTag extends AbstractTag
  {
  
      public static final String TAG = "project";
      public static final String DEFAULT_GOAL_TAG = "default";
  
      private MavenScript script = new MavenScript();
  
      /**
       *
       */
      public MavenTag()
      {
      }
  
      public void begin( String element, Attributes attributes )
          throws TagException, TagalogParseException
      {
          String defGoal = attributes.getValue( DEFAULT_GOAL_TAG );
          script.setDefaultGoal( defGoal );
  
          getContext().put( MavenScript.PARSE_CTX_KEY, script );
      }
  
      public boolean recycle()
      {
          this.script = null;
          return true;
      }
  
      public Object end( String element ) throws TagException, TagalogParseException
      {
          return script;
      }
  
  }
  
  
  
  1.1                  
maven-components/maven-core/src/main/java/org/apache/maven/script/taglib/PostGoalTag.java
  
  Index: PostGoalTag.java
  ===================================================================
  /* Created on Apr 9, 2004 */
  package org.apache.maven.script.taglib;
  
  import org.apache.maven.script.GoalDecorator;
  import org.apache.maven.script.MavenScript;
  
  /**
   * @author jdcasey
   */
  public class PostGoalTag extends AbstractGoalDecoratorTag
  {
  
      public static final String TAG = "postGoal";
  
      /**
       */
      public PostGoalTag()
      {
      }
  
      protected void addDecorator( MavenScript script, GoalDecorator decorator )
      {
          script.addPostGoal( decorator );
      }
  
      protected String getDecoratorClass()
      {
          return "postGoal";
      }
  
  }
  
  
  
  1.1                  
maven-components/maven-core/src/main/java/org/apache/maven/script/taglib/PreGoalTag.java
  
  Index: PreGoalTag.java
  ===================================================================
  /* Created on Apr 9, 2004 */
  package org.apache.maven.script.taglib;
  
  import org.apache.maven.script.GoalDecorator;
  import org.apache.maven.script.MavenScript;
  
  /**
   * @author jdcasey
   */
  public class PreGoalTag extends AbstractGoalDecoratorTag
  {
  
      public static final String TAG = "preGoal";
  
      /**
       */
      public PreGoalTag()
      {
      }
  
      protected void addDecorator( MavenScript script, GoalDecorator decorator )
      {
          script.addPreGoal( decorator );
      }
  
      protected String getDecoratorClass()
      {
          return "preGoal";
      }
  
  }
  
  
  
  1.1                  
maven-components/maven-core/src/test/java/org/apache/maven/lifecycle/phase/GoalDecorationPhaseTest.java
  
  Index: GoalDecorationPhaseTest.java
  ===================================================================
  package org.apache.maven.lifecycle.phase;
  
  import java.io.File;
  import java.net.URL;
  
  import org.apache.maven.MavenConstants;
  import org.apache.maven.MavenPlexusComponentTestBase;
  import org.apache.maven.lifecycle.MavenLifecycleContext;
  import org.apache.maven.project.MavenProject;
  import org.apache.maven.script.MavenScript;
  
  import junit.framework.TestCase;
  
  /**
   * @author jdcasey
   */
  public class GoalDecorationPhaseTest extends MavenPlexusComponentTestBase    
  {
      public GoalDecorationPhaseTest( String name )
      {
          super( name );
      }
  
      public void testShouldDecorateWithPreGoalAndPostGoal() throws Exception
      {
          URL mavenXmlUrl = getClass().getClassLoader().getResource( "maven.xml" );
  
          File mavenXmlFile = new File( mavenXmlUrl.getFile() );
  
          File dir = mavenXmlFile.getParentFile();
  
          MavenProject project = new MavenProject();
  
          project.setFile( new File( dir, "project.xml" ) );
  
          MavenLifecycleContext ctx = new MavenLifecycleContext( getContainer(), 
project, "dummy" );
  
          GoalDecorationPhase phase = new GoalDecorationPhase();
  
          phase.execute( ctx );
  
          MavenScript script = ctx.getScript();
  
          assertNotNull( script );
  
          assertEquals( 1, script.getPreGoals( "dummy" ).size() );
  
          assertEquals( 1, script.getPostGoals( "dummy" ).size() );
  
          assertEquals( "compile", script.getDefaultGoal() );
      }
  
  }
  
  
  

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

Reply via email to