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-core pom.xml
Date Mon, 28 Feb 2005 18:29:47 GMT
jdcasey     2005/02/28 10:29:47

  Modified:    maven-core-it/it0015/src/main/java/org/apache/maven/it0015
                        it0015.mmld
               maven-core-it integration-tests.txt
               maven-plugin-tools/maven-plugin-tools-marmalade/src/test/java/org/apache/maven/tools/plugin/extractor/marmalade
                        MarmaladeMojoDescriptorExtractorTest.java
               maven-mboot2/src/main/java MBoot.java
               maven-plugin-tools/maven-plugin-tools-marmalade/src/main/java/org/apache/maven/tools/plugin/extractor/marmalade
                        MarmaladeMojoDescriptorExtractor.java
               maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags
                        MojoTag.java MetadataTag.java ExecuteTag.java
               maven-core-it/it0015 pom.xml
               maven-plugin-tools/maven-plugin-tools-marmalade pom.xml
               maven-core pom.xml
  Log:
  o Completed marmalade-mojo support, tested with m2 bootstrap with empty local repo and maven-core
pegged at 2/26/2005.
  
    Will resolve CI issues as soon as lifecycle is fixed for IT0013.
  
  Revision  Changes    Path
  1.2       +3 -3      maven-components/maven-core-it/it0015/src/main/java/org/apache/maven/it0015/it0015.mmld
  
  Index: it0015.mmld
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/it0015/src/main/java/org/apache/maven/it0015/it0015.mmld,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- it0015.mmld	25 Feb 2005 05:09:13 -0000	1.1
  +++ it0015.mmld	28 Feb 2005 18:29:46 -0000	1.2
  @@ -1,7 +1,7 @@
   <?xml version="1.0"?>
   
  -<mojo xmlns="marmalade:mojo" xmlns:marmalade-control="marmalade-control">
  -  <metadata marmalade-control:el="none">
  +<mojo xmlns="marmalade:mojo">
  +  <metadata>
       <id>it0015</id>
       <goal>it0015</goal>
       <description>Output a file with specified contents to [outDir]</description>
  @@ -15,6 +15,6 @@
       </parameters>
     </metadata>
     <execute>
  -    <writeFile xmlns="marmalade:it0015" path="${outDir}/out.txt">This is a test.</writeFile>
  +    <it0015:writeFile xmlns:it0015="marmalade:it0015" path="${outDir}/out.txt">This
is a test.</it0015:writeFile>
     </execute>
   </mojo>
  \ No newline at end of file
  
  
  
  1.15      +1 -1      maven-components/maven-core-it/integration-tests.txt
  
  Index: integration-tests.txt
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/integration-tests.txt,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- integration-tests.txt	25 Feb 2005 05:09:14 -0000	1.14
  +++ integration-tests.txt	28 Feb 2005 18:29:47 -0000	1.15
  @@ -13,4 +13,4 @@
   it0012
   it0013
   #it0014
  -#it0015
  +it0015
  
  
  
  1.2       +4 -4      maven-components/maven-plugin-tools/maven-plugin-tools-marmalade/src/test/java/org/apache/maven/tools/plugin/extractor/marmalade/MarmaladeMojoDescriptorExtractorTest.java
  
  Index: MarmaladeMojoDescriptorExtractorTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-marmalade/src/test/java/org/apache/maven/tools/plugin/extractor/marmalade/MarmaladeMojoDescriptorExtractorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MarmaladeMojoDescriptorExtractorTest.java	24 Feb 2005 05:12:29 -0000	1.1
  +++ MarmaladeMojoDescriptorExtractorTest.java	28 Feb 2005 18:29:47 -0000	1.2
  @@ -19,18 +19,18 @@
   import org.apache.maven.model.Model;
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
   import org.apache.maven.project.MavenProject;
  +import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
  +import org.codehaus.plexus.PlexusTestCase;
   
   import java.io.File;
   import java.net.URL;
   import java.util.Set;
   
  -import junit.framework.TestCase;
  -
   /**
    * @author jdcasey
    */
   public class MarmaladeMojoDescriptorExtractorTest
  -    extends TestCase
  +    extends PlexusTestCase
   {
   
       public void testShouldFindOneMojo() throws Exception
  @@ -42,7 +42,7 @@
   
           MavenProject project = new MavenProject( model );
   
  -        MarmaladeMojoDescriptorExtractor extractor = new MarmaladeMojoDescriptorExtractor();
  +        MarmaladeMojoDescriptorExtractor extractor = (MarmaladeMojoDescriptorExtractor)
lookup(MojoDescriptorExtractor.ROLE, "marmalade");
   
           Set descriptors = extractor.execute( basedir.getPath(), project );
   
  
  
  
  1.52      +1 -1      maven-components/maven-mboot2/src/main/java/MBoot.java
  
  Index: MBoot.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-mboot2/src/main/java/MBoot.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- MBoot.java	27 Feb 2005 23:30:07 -0000	1.51
  +++ MBoot.java	28 Feb 2005 18:29:47 -0000	1.52
  @@ -80,8 +80,8 @@
           "maven-model",
           "maven-plugin",
           "maven-artifact",
  -        "maven-core",
           "maven-script/maven-script-marmalade",
  +        "maven-core",
           "maven-plugin-tools/maven-plugin-tools-api",
           "maven-plugin-tools/maven-plugin-tools-java",
           "maven-plugin-tools/maven-plugin-tools-pluggy",
  
  
  
  1.3       +88 -23    maven-components/maven-plugin-tools/maven-plugin-tools-marmalade/src/main/java/org/apache/maven/tools/plugin/extractor/marmalade/MarmaladeMojoDescriptorExtractor.java
  
  Index: MarmaladeMojoDescriptorExtractor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-marmalade/src/main/java/org/apache/maven/tools/plugin/extractor/marmalade/MarmaladeMojoDescriptorExtractor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MarmaladeMojoDescriptorExtractor.java	24 Feb 2005 05:12:30 -0000	1.2
  +++ MarmaladeMojoDescriptorExtractor.java	28 Feb 2005 18:29:47 -0000	1.3
  @@ -19,12 +19,21 @@
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
   import org.apache.maven.project.MavenProject;
   import org.apache.maven.script.marmalade.MarmaladeMojoExecutionDirectives;
  +import org.apache.maven.script.marmalade.tags.MojoTag;
   import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
   import org.apache.maven.tools.plugin.util.PluginUtils;
  +import org.codehaus.marmalade.metamodel.ScriptBuilder;
  +import org.codehaus.marmalade.model.MarmaladeScript;
  +import org.codehaus.marmalade.model.MarmaladeTag;
  +import org.codehaus.marmalade.parsing.DefaultParsingContext;
  +import org.codehaus.marmalade.parsing.MarmaladeParsingContext;
   import org.codehaus.marmalade.parsing.ScriptParser;
  -import org.codehaus.marmalade.util.LazyMansAccess;
  +import org.codehaus.marmalade.runtime.DefaultContext;
  +import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
   
  +import java.io.BufferedReader;
   import java.io.File;
  +import java.io.FileReader;
   import java.util.HashSet;
   import java.util.Map;
   import java.util.Set;
  @@ -37,34 +46,90 @@
       implements MojoDescriptorExtractor
   {
   
  -    private ScriptParser scriptParser = new ScriptParser();
  -
       public Set execute( String sourceDir, MavenProject project ) throws Exception
       {
  -        String[] files = PluginUtils.findSources( sourceDir, "**/*.mmld" );
  -
  -        Set descriptors = new HashSet();
  -
  -        File dir = new File( sourceDir );
  -        for ( int i = 0; i < files.length; i++ )
  +        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
  +        try
           {
  -            String file = files[i];
  -
  -            Map context = new TreeMap();
  -            context.put( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR, sourceDir
);
  -
  -            File scriptFile = new File( dir, file );
  -
  -            context = LazyMansAccess.executeFromFile( scriptFile, context );
  -
  -            MojoDescriptor descriptor = (MojoDescriptor) context.get( MarmaladeMojoExecutionDirectives.METADATA_OUTVAR
);
  -
  -            descriptor.setImplementation( file );
  +            Thread.currentThread().setContextClassLoader(MarmaladeMojoDescriptorExtractor.class.getClassLoader());
  +            
  +            String[] files = PluginUtils.findSources( sourceDir, "**/*.mmld" );
  +
  +            Set descriptors = new HashSet();
  +
  +            File dir = new File( sourceDir );
  +            for ( int i = 0; i < files.length; i++ )
  +            {
  +                String file = files[i];
  +
  +                File scriptFile = new File( dir, file );
  +                
  +                MarmaladeScript script = parse(scriptFile);
  +                
  +                MarmaladeTag rootTag = script.getRoot();
  +                if(rootTag instanceof MojoTag)
  +                {
  +                    Map contextMap = new TreeMap();
  +                    contextMap.put( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
sourceDir );
  +                    
  +                    MarmaladeExecutionContext context = new DefaultContext(contextMap);
  +                    
  +                    script.execute(context);
  +                    
  +                    contextMap = context.getExternalizedVariables();
  +
  +                    MojoDescriptor descriptor = (MojoDescriptor) contextMap.get( MarmaladeMojoExecutionDirectives.METADATA_OUTVAR
);
  +
  +                    descriptors.add( descriptor );
  +                }
  +                else
  +                {
  +                    System.out.println("This script is not a mojo. Its root tag is {element:
" + rootTag.getTagInfo().getElement() + ", class: " + rootTag.getClass().getName() + "}");
  +                }
  +            }
   
  -            descriptors.add( descriptor );
  +            return descriptors;
           }
  +        finally
  +        {
  +            Thread.currentThread().setContextClassLoader(oldCl);
  +        }
  +    }
   
  -        return descriptors;
  +    private MarmaladeScript parse( File scriptFile ) throws Exception
  +    {
  +        BufferedReader reader = null;
  +        
  +        try
  +        {
  +            reader = new BufferedReader(new FileReader(scriptFile));
  +            
  +            MarmaladeParsingContext parsingContext = new DefaultParsingContext();
  +            
  +            parsingContext.setInputLocation(scriptFile.getPath());
  +            parsingContext.setInput(reader);
  +            
  +            ScriptParser parser = new ScriptParser();
  +            
  +            ScriptBuilder builder = parser.parse(parsingContext);
  +            
  +            MarmaladeScript script = builder.build();
  +            
  +            return script;
  +        }
  +        finally
  +        {
  +            if(reader != null)
  +            {
  +                try
  +                {
  +                    reader.close();
  +                }
  +                catch(Exception e)
  +                {
  +                }
  +            }
  +        }
       }
   
   }
  \ No newline at end of file
  
  
  
  1.2       +33 -15    maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags/MojoTag.java
  
  Index: MojoTag.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags/MojoTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MojoTag.java	24 Feb 2005 05:12:28 -0000	1.1
  +++ MojoTag.java	28 Feb 2005 18:29:47 -0000	1.2
  @@ -20,8 +20,12 @@
   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;
   
  +import java.util.Iterator;
  +
   /**
    * Root tag for marmalade-based mojos
    * 
  @@ -32,27 +36,41 @@
       implements PlexusComponentTag
   {
   
  -    private MarmaladeTag realRoot;
  -
  -    protected boolean shouldAddChild( MarmaladeTag child )
  +    protected boolean alwaysProcessChildren()
       {
  -        if ( child instanceof ExecuteTag )
  -        {
  -            this.realRoot = child;
  -
  -            // we don't ever want THIS script to execute the ExecuteTag.
  -            // Instead,
  -            // we pull it out for later wrapping into a new script.
  -            return false;
  -        }
  -        else
  +        return false;
  +    }
  +    
  +    protected void doExecute( MarmaladeExecutionContext context ) throws MarmaladeExecutionException
  +    {
  +        for ( Iterator it = children().iterator(); it.hasNext(); )
           {
  -            return true;
  +            MarmaladeTag child = (MarmaladeTag) it.next();
  +            if(!(child instanceof ExecuteTag))
  +            {
  +                child.execute(context);
  +            }
           }
       }
  -
  +    
       public Object getComponent()
       {
  +        MarmaladeTag realRoot = null;
  +        for ( Iterator it = children().iterator(); it.hasNext(); )
  +        {
  +            MarmaladeTag child = (MarmaladeTag) it.next();
  +            if(child instanceof ExecuteTag)
  +            {
  +                realRoot = child;
  +                break;
  +            }
  +        }
  +        
  +        if(realRoot == null)
  +        {
  +            throw new IllegalStateException("Mojo scripts MUST have a <execute> tag.");
  +        }
  +        
           MarmaladeScript script = new MarmaladeScript( getTagInfo().getSourceFile(), realRoot
);
           return new MarmaladeMojo( script );
       }
  
  
  
  1.3       +10 -7     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MetadataTag.java	25 Feb 2005 05:09:14 -0000	1.2
  +++ MetadataTag.java	28 Feb 2005 18:29:47 -0000	1.3
  @@ -63,7 +63,7 @@
           processChildren( context );
   
           MojoDescriptor descriptor = buildDescriptor( context );
  -        context.setVariable( MarmaladeMojoExecutionDirectives.METADATA_OUTVAR, descriptor
);
  +        context.setVariable( MarmaladeMojoExecutionDirectives.METADATA_OUTVAR, descriptor,
true );
       }
   
       private MojoDescriptor buildDescriptor( MarmaladeExecutionContext context ) throws
MarmaladeExecutionException
  @@ -104,14 +104,17 @@
           String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
                                                           getExpressionEvaluator() );
   
  -        if(basePath.endsWith("/"))
  +        if(basePath != null)
           {
  -            basePath = basePath.substring(0, basePath.length()-2);
  -        }
  -        
  -        String implementationPath = getTagInfo().getSourceFile().substring( basePath.length()
);
  +            if(basePath.endsWith("/"))
  +            {
  +                basePath = basePath.substring(0, basePath.length()-2);
  +            }
  +            
  +            String implementationPath = getTagInfo().getSourceFile().substring( basePath.length()
);
   
  -        descriptor.setImplementation( implementationPath );
  +            descriptor.setImplementation( implementationPath );
  +        }
   
           return descriptor;
       }
  
  
  
  1.2       +14 -0     maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags/ExecuteTag.java
  
  Index: ExecuteTag.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-script/maven-script-marmalade/src/main/java/org/apache/maven/script/marmalade/tags/ExecuteTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExecuteTag.java	24 Feb 2005 05:12:28 -0000	1.1
  +++ ExecuteTag.java	28 Feb 2005 18:29:47 -0000	1.2
  @@ -17,6 +17,11 @@
    */
   
   import org.codehaus.marmalade.model.AbstractMarmaladeTag;
  +import org.codehaus.marmalade.model.MarmaladeTag;
  +import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
  +import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
  +
  +import java.util.Iterator;
   
   /**
    * Aggregator tag for the actual meat of the mojo. Simply a pass-through
  @@ -28,4 +33,13 @@
       extends AbstractMarmaladeTag
   {
   
  +    protected void doExecute( MarmaladeExecutionContext context ) throws MarmaladeExecutionException
  +    {
  +        for ( Iterator it = children().iterator(); it.hasNext(); )
  +        {
  +            MarmaladeTag child = (MarmaladeTag) it.next();
  +            System.out.println("Will execute: " + child);
  +        }
  +    }
  +    
   }
  \ No newline at end of file
  
  
  
  1.3       +5 -0      maven-components/maven-core-it/it0015/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it/it0015/pom.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- pom.xml	25 Feb 2005 05:09:14 -0000	1.2
  +++ pom.xml	28 Feb 2005 18:29:47 -0000	1.3
  @@ -11,6 +11,11 @@
         <version>2.0-SNAPSHOT</version>
       </dependency>
       <dependency>
  +      <groupId>maven</groupId>
  +      <artifactId>maven-script-marmalade</artifactId>
  +      <version>2.0-SNAPSHOT</version>
  +    </dependency>
  +    <dependency>
         <groupId>marmalade</groupId>
         <artifactId>marmalade-core</artifactId>
         <version>1.0-alpha2-SNAPSHOT</version>
  
  
  
  1.3       +22 -2     maven-components/maven-plugin-tools/maven-plugin-tools-marmalade/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-marmalade/pom.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- pom.xml	24 Feb 2005 05:12:30 -0000	1.2
  +++ pom.xml	28 Feb 2005 18:29:47 -0000	1.3
  @@ -13,6 +13,11 @@
     <version>2.0-SNAPSHOT</version>
     <dependencies>
       <dependency>
  +      <groupId>plexus</groupId>
  +      <artifactId>plexus-container-default</artifactId>
  +      <version>1.0-alpha-2-SNAPSHOT</version>
  +    </dependency>
  +    <dependency>
         <groupId>marmalade</groupId>
         <artifactId>marmalade-core</artifactId>
         <version>1.0-alpha2-SNAPSHOT</version>
  @@ -37,13 +42,28 @@
         <artifactId>maven-core</artifactId>
         <version>2.0-SNAPSHOT</version>
       </dependency>
  -<!--
  +<!-- For testing. -->
       <dependency>
         <groupId>maven</groupId>
         <artifactId>maven-artifact</artifactId>
         <version>2.0-SNAPSHOT</version>
       </dependency>
  --->
  +    <dependency>
  +      <groupId>maven</groupId>
  +      <artifactId>wagon-provider-api</artifactId>
  +      <version>1.0-alpha-2-SNAPSHOT</version>
  +    </dependency>
  +    <dependency>
  +      <groupId>maven</groupId>
  +      <artifactId>wagon-http-lightweight</artifactId>
  +      <version>1.0-alpha-2-SNAPSHOT</version>
  +    </dependency>
  +    <dependency>
  +      <groupId>maven</groupId>
  +      <artifactId>wagon-file</artifactId>
  +      <version>1.0-alpha-2-SNAPSHOT</version>
  +    </dependency>
  +<!-- /For testing. -->
       <dependency>
         <groupId>maven</groupId>
         <artifactId>maven-model</artifactId>
  
  
  
  1.18      +5 -0      maven-components/maven-core/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/pom.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- pom.xml	25 Feb 2005 05:09:14 -0000	1.17
  +++ pom.xml	28 Feb 2005 18:29:47 -0000	1.18
  @@ -67,6 +67,11 @@
         <version>1.0-alpha-2-SNAPSHOT</version>
       </dependency>
       <dependency>
  +      <groupId>maven</groupId>
  +      <artifactId>maven-script-marmalade</artifactId>
  +      <version>2.0-SNAPSHOT</version>
  +    </dependency>
  +    <dependency>
         <groupId>marmalade</groupId>
         <artifactId>marmalade-core</artifactId>
         <version>1.0-alpha2-SNAPSHOT</version>
  
  
  

Mime
View raw message