mirror of https://github.com/apache/maven.git
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:
parent
cad43e6b56
commit
9af145d0a7
|
@ -238,7 +238,7 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
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 @@ public class DefaultLifecycleExecutor
|
|||
//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
|
||||
|
@ -386,10 +386,10 @@ public class DefaultLifecycleExecutor
|
|||
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,21 +398,23 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
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
|
||||
* non-applicable parameters. This is necessary because a plugin execution can have multiple goals with different
|
||||
|
|
|
@ -227,22 +227,12 @@ problem.
|
|||
<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>
|
||||
|
|
|
@ -135,51 +135,47 @@ public class LifecycleExecutorTest
|
|||
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
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|||
* @author Benjamin Bentmann
|
||||
* @version $Id: Xpp3DomPointerFactory.java 737056 2009-01-23 15:35:43Z bentmann $
|
||||
*/
|
||||
class Xpp3DomPointerFactory
|
||||
public class Xpp3DomPointerFactory
|
||||
implements NodePointerFactory
|
||||
{
|
||||
|
||||
|
|
|
@ -41,34 +41,6 @@ under the License.
|
|||
<artifactId>modello-maven-plugin</artifactId>
|
||||
<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>
|
||||
|
|
Loading…
Reference in New Issue