You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2009/05/21 18:18:53 UTC

svn commit: r777166 - in /maven/components/branches/MNG-2766/maven-core/src: main/java/org/apache/maven/lifecycle/ main/resources/META-INF/plexus/ test/java/org/apache/maven/lifecycle/ test/java/org/apache/maven/project/harness/ test/projects/lifecycle...

Author: jvanzyl
Date: Thu May 21 16:18:53 2009
New Revision: 777166

URL: http://svn.apache.org/viewvc?rev=777166&view=rev
Log:
o take the plugin update registry out of the lifecycle mapping for plugins
o change the way mojo executions are processed and match up the executions when extracting configuration
o give mojo executions originating from the CLI the "default-<goal>" execution id


Added:
    maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java   (with props)
Modified:
    maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/components/branches/MNG-2766/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml
    maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
    maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java
    maven/components/branches/MNG-2766/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/pom.xml

Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=777166&r1=777165&r2=777166&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Thu May 21 16:18:53 2009
@@ -238,7 +238,7 @@
             {
                 MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
 
-                MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
+                MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, "default-" + mojoDescriptor.getGoal() );
                 
                 populateMojoExecutionConfiguration( project, mojoExecution );
 
@@ -280,7 +280,7 @@
                     //TODO: remove hard coding
                     if ( phase.equals( "clean" ) )
                     {
-                        mojos.add( new MojoExecution( "org.apache.maven.plugins", "maven-clean-plugin", "2.3", "clean", null ) );
+                        mojos.add( new MojoExecution( "org.apache.maven.plugins", "maven-clean-plugin", "2.3", "clean", "default-clean" ) );
                     }
 
                     // This is just just laying out the initial structure of the mojos to run in each phase of the
@@ -385,11 +385,11 @@
         sb.append( "Executing " + pd.getArtifactId() + "[" + pd.getVersion() + "]: " + me.getMojoDescriptor().getGoal() + " on " + project.getArtifactId() );        
         return sb.toString();
     }
-    
-    //this will get the wrong configuration because it's only matching the goal not the execution id
-    
+        
     private void populateMojoExecutionConfiguration( MavenProject project, MojoExecution mojoExecution )
-    {                
+    {
+        //System.out.println( mojoExecution.getGoal() + " : executionid: " + mojoExecution.getExecutionId() );
+        
         String g = mojoExecution.getGroupId();
 
         String a = mojoExecution.getArtifactId();
@@ -398,20 +398,22 @@
 
         for ( PluginExecution e : p.getExecutions() )
         {
-            for ( String goal : e.getGoals() )
+            if ( mojoExecution.getExecutionId().equals( e.getId() ) )
             {
-                if ( mojoExecution.getGoal().equals( goal ) )
+                for ( String goal : e.getGoals() )
                 {
-                    Xpp3Dom executionConfiguration = (Xpp3Dom) e.getConfiguration();
+                    if ( mojoExecution.getGoal().equals( goal ) )
+                    {
+                        Xpp3Dom executionConfiguration = (Xpp3Dom) e.getConfiguration();
 
-                    Xpp3Dom mojoConfiguration = extractMojoConfiguration( executionConfiguration, mojoExecution.getMojoDescriptor() );
+                        Xpp3Dom mojoConfiguration = extractMojoConfiguration( executionConfiguration, mojoExecution.getMojoDescriptor() );
 
-                    mojoExecution.setConfiguration( mojoConfiguration );
+                        mojoExecution.setConfiguration( mojoConfiguration );
+                    }
                 }
             }
         }
-    }
-    
+    }    
     
     /**
      * Extracts the configuration for a single mojo from the specified execution configuration by discarding any

Modified: maven/components/branches/MNG-2766/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml?rev=777166&r1=777165&r2=777166&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/resources/META-INF/plexus/artifact-handlers.xml Thu May 21 16:18:53 2009
@@ -227,22 +227,12 @@
               <generate-resources>org.apache.maven.plugins:maven-plugin-plugin:descriptor</generate-resources>
               <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
               <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
-              <process-test-resources>
-                org.apache.maven.plugins:maven-resources-plugin:testResources
-              </process-test-resources>
-              <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
+              <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources
+              </process-test-resources><test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
               <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
-              <package>
-                org.apache.maven.plugins:maven-jar-plugin:jar,
-                org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata
-              </package>
-              <install>
-                org.apache.maven.plugins:maven-install-plugin:install,
-                org.apache.maven.plugins:maven-plugin-plugin:updateRegistry
-              </install>
-              <deploy>
-                org.apache.maven.plugins:maven-deploy-plugin:deploy
-              </deploy>
+              <package>org.apache.maven.plugins:maven-jar-plugin:jar,org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata</package>
+              <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+              <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
             </phases>
             <!-- END SNIPPET: maven-plugin-lifecycle -->
           </lifecycle>

Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java?rev=777166&r1=777165&r2=777166&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java Thu May 21 16:18:53 2009
@@ -134,51 +134,47 @@
         assertEquals( "project-with-multiple-executions", session.getCurrentProject().getArtifactId() );
         assertEquals( "1.0.1", session.getCurrentProject().getVersion() );
         List<MojoExecution> lifecyclePlan = lifecycleExecutor.calculateBuildPlan( session, "clean", "install" );        
-
-        /*
-        for ( Plugin p : session.getCurrentProject().getBuildPlugins() )
-        {
-            for ( PluginExecution pe : p.getExecutions() )
-            {
-                System.out.println( pe.getConfiguration() );
-            }
-        }
-        
-        for ( MojoExecution me : lifecyclePlan )
-        {
-            System.out.println( me.getMojoDescriptor().getFullGoalName() );
-            //System.out.println( me.getConfiguration() ) ;
-        }
-        */
         
-        /*
         //[01] clean:clean
-        //[02] resources:resources
-        //[03] compiler:compile
-        //[04] plexus-component-metadata:generate-metadata
-        //[05] resources:testResources
-        //[06] compiler:testCompile
-        //[07] plexus-component-metadata:generate-test-metadata
-        //[08] surefire:test
-        //[09] jar:jar
-        //[10] install:install
+        //[02] modello:xpp3-writer
+        //[03] modello:java
+        //[04] modello:xpp3-reader
+        //[05] modello:xpp3-writer
+        //[06] modello:java
+        //[07] modello:xpp3-reader
+        //[08] plugin:descriptor        
+        //[09] resources:resources
+        //[10] compiler:compile
+        //[11] resources:testResources
+        //[12] compiler:testCompile
+        //[13] surefire:test
+        //[14] plugin:addPluginArtifactMetadata        
+        //[15] jar:jar
+        //[16] install:install
         //
-        assertEquals( 10, lifecyclePlan.size() );
+        
+        assertEquals( 16, lifecyclePlan.size() );        
                 
         assertEquals( "clean:clean", lifecyclePlan.get( 0 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "resources:resources", lifecyclePlan.get( 1 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "compiler:compile", lifecyclePlan.get( 2 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "plexus-component-metadata:generate-metadata", lifecyclePlan.get( 3 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "resources:testResources", lifecyclePlan.get( 4 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "compiler:testCompile", lifecyclePlan.get( 5 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "plexus-component-metadata:generate-test-metadata", lifecyclePlan.get( 6 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "surefire:test", lifecyclePlan.get( 7 ).getMojoDescriptor().getFullGoalName() );
-        assertEquals( "jar:jar", lifecyclePlan.get( 8 ).getMojoDescriptor().getFullGoalName() );                
-        assertEquals( "install:install", lifecyclePlan.get( 9 ).getMojoDescriptor().getFullGoalName() );
-        */                
-    }
-    
-    
+        assertEquals( "modello:xpp3-writer", lifecyclePlan.get( 1 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "modello:java", lifecyclePlan.get( 2 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "modello:xpp3-reader", lifecyclePlan.get( 3 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "modello:xpp3-writer", lifecyclePlan.get( 4 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "modello:java", lifecyclePlan.get( 5 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "modello:xpp3-reader", lifecyclePlan.get( 6 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "plugin:descriptor", lifecyclePlan.get( 7 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "resources:resources", lifecyclePlan.get( 8 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "compiler:compile", lifecyclePlan.get( 9 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "resources:testResources", lifecyclePlan.get( 10 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "compiler:testCompile", lifecyclePlan.get( 11 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "surefire:test", lifecyclePlan.get( 12 ).getMojoDescriptor().getFullGoalName() );
+        assertEquals( "plugin:addPluginArtifactMetadata", lifecyclePlan.get( 13 ).getMojoDescriptor().getFullGoalName() );                
+        assertEquals( "jar:jar", lifecyclePlan.get( 14 ).getMojoDescriptor().getFullGoalName() );                
+        assertEquals( "install:install", lifecyclePlan.get( 15 ).getMojoDescriptor().getFullGoalName() );
+        
+        assertEquals( "src/main/mdo/remote-resources.mdo", new MojoExecutionXPathContainer( lifecyclePlan.get( 1 ) ).getValue( "configuration/models[1]/model" ) );
+        assertEquals( "src/main/mdo/supplemental-model.mdo", new MojoExecutionXPathContainer( lifecyclePlan.get( 4 ) ).getValue( "configuration/models[1]/model" ) );
+    }        
     
     public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanCleanGoal()
         throws Exception

Added: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java?rev=777166&view=auto
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java (added)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java Thu May 21 16:18:53 2009
@@ -0,0 +1,75 @@
+package org.apache.maven.lifecycle;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.jxpath.JXPathNotFoundException;
+import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.project.harness.Xpp3DomPointerFactory;
+
+public class MojoExecutionXPathContainer
+{
+    private JXPathContext context;
+
+    private MojoExecution mojoExecution;
+
+    static
+    {
+        JXPathContextReferenceImpl.addNodePointerFactory( new Xpp3DomPointerFactory() );
+    }
+
+    public MojoExecutionXPathContainer( MojoExecution mojoExecution )
+        throws IOException
+    {
+        this.mojoExecution = mojoExecution;
+        context = JXPathContext.newContext( mojoExecution );
+    }
+
+	public Iterator<?> getIteratorForXPathExpression( String expression )
+    {
+        return context.iterate( expression );
+    }
+
+    public boolean containsXPathExpression( String expression )
+    {
+        return context.getValue( expression ) != null;
+    }
+
+    public Object getValue( String expression )
+    {
+        try
+        {
+            return context.getValue( expression );
+        }
+        catch ( JXPathNotFoundException e )
+        {
+            return null;
+        }
+    }
+
+    public boolean xPathExpressionEqualsValue( String expression, String value )
+    {
+        return context.getValue( expression ) != null && context.getValue( expression ).equals( value );
+    }
+}

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/lifecycle/MojoExecutionXPathContainer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java?rev=777166&r1=777165&r2=777166&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/harness/Xpp3DomPointerFactory.java Thu May 21 16:18:53 2009
@@ -32,7 +32,7 @@
  * @author Benjamin Bentmann
  * @version $Id: Xpp3DomPointerFactory.java 737056 2009-01-23 15:35:43Z bentmann $
  */
-class Xpp3DomPointerFactory
+public class Xpp3DomPointerFactory
     implements NodePointerFactory
 {
 

Modified: maven/components/branches/MNG-2766/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/pom.xml?rev=777166&r1=777165&r2=777166&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/pom.xml (original)
+++ maven/components/branches/MNG-2766/maven-core/src/test/projects/lifecycle-executor/project-with-multiple-executions/pom.xml Thu May 21 16:18:53 2009
@@ -42,34 +42,6 @@
         <version>1.0.1</version>
         <executions>
           <execution>
-            <id>site-docs</id>
-            <phase>pre-site</phase>
-            <goals>
-              <goal>xdoc</goal>
-              <goal>xsd</goal>
-            </goals>
-            <configuration>
-              <version>1.0.0</version>
-              <models>
-                <model>src/main/mdo/supplemental-model.mdo</model>
-              </models>
-            </configuration>
-          </execution>
-          <execution>
-            <id>site-docs-supplement</id>
-            <phase>pre-site</phase>
-            <goals>
-              <goal>xdoc</goal>
-              <goal>xsd</goal>
-            </goals>
-            <configuration>
-              <version>1.1.0</version>
-              <models>
-                <model>src/main/mdo/remote-resources.mdo</model>
-              </models>
-            </configuration>
-          </execution>
-          <execution>
             <id>remote-resources</id>
             <goals>
               <goal>xpp3-writer</goal>