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



git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@777166 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-05-21 16:18:53 +00:00
parent cad43e6b56
commit 9af145d0a7
6 changed files with 132 additions and 97 deletions

View File

@ -238,7 +238,7 @@ public List<MojoExecution> calculateBuildPlan( MavenSession session, String...
{ {
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session ); MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor ); MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, "default-" + mojoDescriptor.getGoal() );
populateMojoExecutionConfiguration( project, mojoExecution ); populateMojoExecutionConfiguration( project, mojoExecution );
@ -280,7 +280,7 @@ public List<MojoExecution> calculateBuildPlan( MavenSession session, String...
//TODO: remove hard coding //TODO: remove hard coding
if ( phase.equals( "clean" ) ) 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 // This is just just laying out the initial structure of the mojos to run in each phase of the
@ -385,11 +385,11 @@ private String executionDescription( MojoExecution me, MavenProject project )
sb.append( "Executing " + pd.getArtifactId() + "[" + pd.getVersion() + "]: " + me.getMojoDescriptor().getGoal() + " on " + project.getArtifactId() ); sb.append( "Executing " + pd.getArtifactId() + "[" + pd.getVersion() + "]: " + me.getMojoDescriptor().getGoal() + " on " + project.getArtifactId() );
return sb.toString(); 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 ) private void populateMojoExecutionConfiguration( MavenProject project, MojoExecution mojoExecution )
{ {
//System.out.println( mojoExecution.getGoal() + " : executionid: " + mojoExecution.getExecutionId() );
String g = mojoExecution.getGroupId(); String g = mojoExecution.getGroupId();
String a = mojoExecution.getArtifactId(); String a = mojoExecution.getArtifactId();
@ -398,20 +398,22 @@ private void populateMojoExecutionConfiguration( MavenProject project, MojoExecu
for ( PluginExecution e : p.getExecutions() ) 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 * Extracts the configuration for a single mojo from the specified execution configuration by discarding any

View File

@ -227,22 +227,12 @@ problem.
<generate-resources>org.apache.maven.plugins:maven-plugin-plugin:descriptor</generate-resources> <generate-resources>org.apache.maven.plugins:maven-plugin-plugin:descriptor</generate-resources>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources> <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile> <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
<process-test-resources> <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources
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>
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test> <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package> <package>org.apache.maven.plugins:maven-jar-plugin:jar,org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata</package>
org.apache.maven.plugins:maven-jar-plugin:jar, <install>org.apache.maven.plugins:maven-install-plugin:install</install>
org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</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>
</phases> </phases>
<!-- END SNIPPET: maven-plugin-lifecycle --> <!-- END SNIPPET: maven-plugin-lifecycle -->
</lifecycle> </lifecycle>

View File

@ -134,51 +134,47 @@ public void testCalculationOfBuildPlanWithMultipleExecutionsOfModello()
assertEquals( "project-with-multiple-executions", session.getCurrentProject().getArtifactId() ); assertEquals( "project-with-multiple-executions", session.getCurrentProject().getArtifactId() );
assertEquals( "1.0.1", session.getCurrentProject().getVersion() ); assertEquals( "1.0.1", session.getCurrentProject().getVersion() );
List<MojoExecution> lifecyclePlan = lifecycleExecutor.calculateBuildPlan( session, "clean", "install" ); 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 //[01] clean:clean
//[02] resources:resources //[02] modello:xpp3-writer
//[03] compiler:compile //[03] modello:java
//[04] plexus-component-metadata:generate-metadata //[04] modello:xpp3-reader
//[05] resources:testResources //[05] modello:xpp3-writer
//[06] compiler:testCompile //[06] modello:java
//[07] plexus-component-metadata:generate-test-metadata //[07] modello:xpp3-reader
//[08] surefire:test //[08] plugin:descriptor
//[09] jar:jar //[09] resources:resources
//[10] install:install //[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( "clean:clean", lifecyclePlan.get( 0 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "resources:resources", lifecyclePlan.get( 1 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "modello:xpp3-writer", lifecyclePlan.get( 1 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "compiler:compile", lifecyclePlan.get( 2 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "modello:java", lifecyclePlan.get( 2 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "plexus-component-metadata:generate-metadata", lifecyclePlan.get( 3 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "modello:xpp3-reader", lifecyclePlan.get( 3 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "resources:testResources", lifecyclePlan.get( 4 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "modello:xpp3-writer", lifecyclePlan.get( 4 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "compiler:testCompile", lifecyclePlan.get( 5 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "modello:java", lifecyclePlan.get( 5 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "plexus-component-metadata:generate-test-metadata", lifecyclePlan.get( 6 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "modello:xpp3-reader", lifecyclePlan.get( 6 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "surefire:test", lifecyclePlan.get( 7 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "plugin:descriptor", lifecyclePlan.get( 7 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "jar:jar", lifecyclePlan.get( 8 ).getMojoDescriptor().getFullGoalName() ); assertEquals( "resources:resources", lifecyclePlan.get( 8 ).getMojoDescriptor().getFullGoalName() );
assertEquals( "install:install", lifecyclePlan.get( 9 ).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() public void testCalculationOfBuildPlanWithIndividualTaskOfTheCleanCleanGoal()
throws Exception throws Exception

View File

@ -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 );
}
}

View File

@ -32,7 +32,7 @@
* @author Benjamin Bentmann * @author Benjamin Bentmann
* @version $Id: Xpp3DomPointerFactory.java 737056 2009-01-23 15:35:43Z bentmann $ * @version $Id: Xpp3DomPointerFactory.java 737056 2009-01-23 15:35:43Z bentmann $
*/ */
class Xpp3DomPointerFactory public class Xpp3DomPointerFactory
implements NodePointerFactory implements NodePointerFactory
{ {

View File

@ -41,34 +41,6 @@ under the License.
<artifactId>modello-maven-plugin</artifactId> <artifactId>modello-maven-plugin</artifactId>
<version>1.0.1</version> <version>1.0.1</version>
<executions> <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> <execution>
<id>remote-resources</id> <id>remote-resources</id>
<goals> <goals>