You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/06/13 04:47:59 UTC
svn commit: r190335 - /maven/components/trunk/maven-core-it
/maven/components/trunk/maven-core-it/it0024
/maven/components/trunk/maven-core-it/it0024/src
/maven/components/trunk/maven-core-it/it0024/src/main
/maven/components/trunk/maven-core-it/it0024/src/main/java
/maven/components/trunk/maven-core-it/it0024/src/main/java/org
/maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache
/maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven
/maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001
/maven/components/trunk/maven-core-it/it0024/src/test
/maven/components/trunk/maven-core-it/it0024/src/test/java
/maven/components/trunk/maven-core-it/it0024/src/test/java/org
/maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache
/maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven
/maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001
/maven/components/trunk/maven-core-it/it0025
/maven/components/trunk/maven-core-it/it0025/src
/maven/components/trunk/maven-core-it/it0025/src/main
/maven/components/trunk/maven-core-it/it0025/src/main/java
/maven/components/trunk/maven-core-it/it0025/src/main/java/org
/maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache
/maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven
/maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023
/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle
/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin
/maven/components/trunk/maven-model
/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor
/maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin
/maven/components/trunk/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy
/maven/components/trunk/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install
/maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin
/maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources
/maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test
/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project
/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project
Author: jdcasey
Date: Sun Jun 12 19:47:57 2005
New Revision: 190335
URL: http://svn.apache.org/viewcvs?rev=190335&view=rev
Log:
o Adding support for <executions/>, which means multiple runs of the same goal/set-of-goals with different configs.
o Adding @phase declarations for those mojos that seem to be part of the main build, just for completeness
o Added two ITs, to test that <executions/> doesn't mess up the normal operation, and to test multi-execution for a goal.
Should resolve: MNG-172.
Added:
maven/components/trunk/maven-core-it/it0024/
maven/components/trunk/maven-core-it/it0024/expected-results.txt (with props)
maven/components/trunk/maven-core-it/it0024/goals.txt (with props)
maven/components/trunk/maven-core-it/it0024/pom.xml (with props)
maven/components/trunk/maven-core-it/it0024/src/
maven/components/trunk/maven-core-it/it0024/src/main/
maven/components/trunk/maven-core-it/it0024/src/main/java/
maven/components/trunk/maven-core-it/it0024/src/main/java/org/
maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/
maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/
maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001/
maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001/Person.java (with props)
maven/components/trunk/maven-core-it/it0024/src/test/
maven/components/trunk/maven-core-it/it0024/src/test/java/
maven/components/trunk/maven-core-it/it0024/src/test/java/org/
maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/
maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/
maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001/
maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001/PersonTest.java (with props)
maven/components/trunk/maven-core-it/it0025/
maven/components/trunk/maven-core-it/it0025/expected-results.txt (with props)
maven/components/trunk/maven-core-it/it0025/goals.txt (with props)
maven/components/trunk/maven-core-it/it0025/pom.xml (with props)
maven/components/trunk/maven-core-it/it0025/src/
maven/components/trunk/maven-core-it/it0025/src/main/
maven/components/trunk/maven-core-it/it0025/src/main/java/
maven/components/trunk/maven-core-it/it0025/src/main/java/org/
maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/
maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/
maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023/
maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023/Person.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/GoalInstance.java (with props)
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java (with props)
Modified:
maven/components/trunk/maven-core-it/README.txt
maven/components/trunk/maven-core-it/integration-tests.txt
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
maven/components/trunk/maven-model/maven.mdo
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java
maven/components/trunk/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
maven/components/trunk/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/TestResourcesMojo.java
maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
Modified: maven/components/trunk/maven-core-it/README.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/README.txt (original)
+++ maven/components/trunk/maven-core-it/README.txt Sun Jun 12 19:47:57 2005
@@ -76,6 +76,11 @@
it0023: Test profile inclusion from settings.xml (this one is activated by an id
in the activeProfiles section).
+it0024: Test usage of <executions/> inside a plugin rather than <goals/>
+ that are directly inside th plugin.
+
+it0025: Test multiple goal executions with different execution-level configs.
+
-------------------------------------------------------------------------------
- generated sources
Modified: maven/components/trunk/maven-core-it/integration-tests.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/integration-tests.txt?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/integration-tests.txt (original)
+++ maven/components/trunk/maven-core-it/integration-tests.txt Sun Jun 12 19:47:57 2005
@@ -22,3 +22,5 @@
it0021
it0022
it0023
+it0024
+it0025
Added: maven/components/trunk/maven-core-it/it0024/expected-results.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0024/expected-results.txt?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0024/expected-results.txt (added)
+++ maven/components/trunk/maven-core-it/it0024/expected-results.txt Sun Jun 12 19:47:57 2005
@@ -0,0 +1 @@
+target/classes/org/apache/maven/it0001/Person.class
Propchange: maven/components/trunk/maven-core-it/it0024/expected-results.txt
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0024/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0024/goals.txt?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0024/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it0024/goals.txt Sun Jun 12 19:47:57 2005
@@ -0,0 +1 @@
+test
Propchange: maven/components/trunk/maven-core-it/it0024/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0024/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0024/pom.xml?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0024/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0024/pom.xml Sun Jun 12 19:47:57 2005
@@ -0,0 +1,41 @@
+<model>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core-it0024</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+
+ <executions>
+ <execution>
+ <id>test</id>
+
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+
+ <goals>
+ <goal>
+ <id>compile</id>
+ </goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</model>
Propchange: maven/components/trunk/maven-core-it/it0024/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Propchange: maven/components/trunk/maven-core-it/it0024/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001/Person.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001/Person.java?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001/Person.java (added)
+++ maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001/Person.java Sun Jun 12 19:47:57 2005
@@ -0,0 +1,18 @@
+package org.apache.maven.it0001;
+
+public class Person
+{
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+
+ assert true;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Propchange: maven/components/trunk/maven-core-it/it0024/src/main/java/org/apache/maven/it0001/Person.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001/PersonTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001/PersonTest.java?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001/PersonTest.java (added)
+++ maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001/PersonTest.java Sun Jun 12 19:47:57 2005
@@ -0,0 +1,16 @@
+package org.apache.maven.it0001;
+
+import junit.framework.TestCase;
+
+public class PersonTest
+ extends TestCase
+{
+ public void testPerson()
+ {
+ Person person = new Person();
+
+ person.setName( "foo" );
+
+ assertEquals( "foo", person.getName() );
+ }
+}
Propchange: maven/components/trunk/maven-core-it/it0024/src/test/java/org/apache/maven/it0001/PersonTest.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0025/expected-results.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0025/expected-results.txt?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0025/expected-results.txt (added)
+++ maven/components/trunk/maven-core-it/it0025/expected-results.txt Sun Jun 12 19:47:57 2005
@@ -0,0 +1,2 @@
+target/test.txt
+target/test2.txt
Propchange: maven/components/trunk/maven-core-it/it0025/expected-results.txt
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0025/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0025/goals.txt?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0025/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it0025/goals.txt Sun Jun 12 19:47:57 2005
@@ -0,0 +1 @@
+core-it:touch
\ No newline at end of file
Propchange: maven/components/trunk/maven-core-it/it0025/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0025/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0025/pom.xml?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0025/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0025/pom.xml Sun Jun 12 19:47:57 2005
@@ -0,0 +1,44 @@
+<model>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.</groupId>
+ <artifactId>maven-it0025</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-core-it-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>test1</id>
+
+ <configuration>
+ <pluginItem>test.txt</pluginItem>
+ </configuration>
+
+ <goals>
+ <goal>
+ <id>touch</id>
+ </goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>test2</id>
+
+ <configuration>
+ <pluginItem>test2.txt</pluginItem>
+ </configuration>
+
+ <goals>
+ <goal>
+ <id>touch</id>
+ </goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</model>
Propchange: maven/components/trunk/maven-core-it/it0025/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Propchange: maven/components/trunk/maven-core-it/it0025/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023/Person.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023/Person.java?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023/Person.java (added)
+++ maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023/Person.java Sun Jun 12 19:47:57 2005
@@ -0,0 +1,16 @@
+package org.apache.maven.it0023;
+
+public class Person
+{
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Propchange: maven/components/trunk/maven-core-it/it0025/src/main/java/org/apache/maven/it0023/Person.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Sun Jun 12 19:47:57 2005
@@ -22,7 +22,9 @@
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
import org.apache.maven.model.Goal;
import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
+import org.apache.maven.plugin.GoalInstance;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginManagerException;
@@ -110,6 +112,7 @@
ArtifactResolutionException
{
Map phaseMap = new HashMap();
+ Map goalInstanceMap = new HashMap();
for ( Iterator i = phases.iterator(); i.hasNext(); )
{
@@ -136,47 +139,119 @@
for ( Iterator i = mappings.keySet().iterator(); i.hasNext(); )
{
String phase = (String) i.next();
+
String task = (String) mappings.get( phase );
+
MojoDescriptor mojoDescriptor = configureMojo( task, session, phaseMap );
- List goals = (List) phaseMap.get( phase );
- if ( !goals.contains( mojoDescriptor.getId() ) )
+
+ addToPhaseMap( phaseMap, phase, mojoDescriptor );
+
+ List matchingGoalInstances = findMatchingGoalInstances( mojoDescriptor, project );
+
+ for ( Iterator instanceIterator = matchingGoalInstances.iterator(); instanceIterator.hasNext(); )
{
- goals.add( mojoDescriptor.getId() );
+ GoalInstance goalInstance = (GoalInstance) instanceIterator.next();
+
+ addToGoalInstanceMap( goalInstanceMap, goalInstance );
}
}
- processPluginConfiguration( project, session, phaseMap );
+ processPluginConfiguration( project, session, phaseMap, goalInstanceMap );
for ( Iterator i = tasks.iterator(); i.hasNext(); )
{
String task = (String) i.next();
+ // verify that all loose-leaf goals have had GoalInstance(s) configured for them...
+ // we only need to do this if the current task is not a phase name.
+ if ( !phaseMap.containsKey( task ) )
+ {
+ MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
+
+ if ( mojoDescriptor != null && !goalInstanceMap.containsKey( mojoDescriptor ) )
+ {
+ List matchingGoalInstances = findMatchingGoalInstances( mojoDescriptor, project );
+
+ for ( Iterator instanceIterator = matchingGoalInstances.iterator(); instanceIterator.hasNext(); )
+ {
+ GoalInstance goalInstance = (GoalInstance) instanceIterator.next();
+
+ addToGoalInstanceMap( goalInstanceMap, goalInstance );
+ }
+ }
+ }
+
+ // now we can proceed to actually load up the list of goals we're interested in.
List goals = processGoalChain( task, session, phaseMap );
for ( Iterator j = goals.iterator(); j.hasNext(); )
{
- MojoDescriptor mojo = (MojoDescriptor) j.next();
+ MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
- if ( mojo.getExecutePhase() != null )
- {
- // TODO: is this too broad to execute?
- execute( Collections.singletonList( mojo.getExecutePhase() ), session );
- }
+ List instances = (List) goalInstanceMap.get( mojoDescriptor );
- try
+ if ( instances != null )
{
- pluginManager.executeMojo( session, mojo );
+ for ( Iterator instanceIterator = instances.iterator(); instanceIterator.hasNext(); )
+ {
+ GoalInstance instance = (GoalInstance) instanceIterator.next();
+
+ String executePhase = mojoDescriptor.getExecutePhase();
+
+ if ( executePhase != null )
+ {
+ // TODO: is this too broad to execute?
+ execute( Collections.singletonList( executePhase ), session );
+ }
+
+ try
+ {
+ pluginManager.executeMojo( session, instance );
+ }
+ catch ( PluginManagerException e )
+ {
+ throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+ }
+ }
}
- catch ( PluginManagerException e )
+ else
{
- throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
+ throw new LifecycleExecutionException( "This goal has not been configured: "
+ + mojoDescriptor.getGoal() );
}
}
}
}
+ private void addToGoalInstanceMap( Map goalInstanceMap, GoalInstance goalInstance )
+ {
+ MojoDescriptor mojoDescriptor = goalInstance.getMojoDescriptor();
+
+ List instances = (List) goalInstanceMap.get( mojoDescriptor );
+
+ if ( instances == null )
+ {
+ instances = new ArrayList();
+
+ goalInstanceMap.put( mojoDescriptor, instances );
+ }
+
+ int idx = instances.indexOf( goalInstance );
+
+ if ( idx > -1 )
+ {
+ GoalInstance cached = (GoalInstance) instances.get( idx );
+
+ cached.incorporate( goalInstance );
+ }
+ else
+ {
+ instances.add( goalInstance );
+ }
+ }
+
private void injectHandlerPluginConfiguration( MavenProject project, String groupId, String artifactId,
- String version )
+ String version )
{
String key = Plugin.constructKey( groupId, artifactId );
Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( key );
@@ -202,14 +277,15 @@
}
}
- private void processPluginConfiguration( MavenProject project, MavenSession mavenSession, Map phaseMap )
+ private void processPluginConfiguration( MavenProject project, MavenSession mavenSession, Map phaseMap,
+ Map goalInstanceMap )
throws LifecycleExecutionException, ArtifactResolutionException
{
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
{
Plugin plugin = (Plugin) i.next();
- processPluginPhases( plugin, mavenSession, phaseMap );
+ processPluginPhases( plugin, mavenSession, phaseMap, goalInstanceMap );
}
}
@@ -219,8 +295,9 @@
* to execute for that given phase.
*
* @param session
+ * @param goalInstanceMap
*/
- private void processPluginPhases( Plugin plugin, MavenSession session, Map phaseMap )
+ private void processPluginPhases( Plugin plugin, MavenSession session, Map phaseMap, Map goalInstanceMap )
throws LifecycleExecutionException, ArtifactResolutionException
{
String groupId = plugin.getGroupId();
@@ -232,8 +309,8 @@
PluginDescriptor pluginDescriptor;
try
{
- pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, session.getProject(),
- session.getLocalRepository() );
+ pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, session.getProject(), session
+ .getLocalRepository() );
}
catch ( PluginManagerException e )
{
@@ -242,40 +319,68 @@
if ( plugin.isInheritanceApplied() || pluginDescriptor.isInheritedByDefault() )
{
- // ----------------------------------------------------------------------
- // Look to see if the plugin configuration specifies particular mojos
- // within the plugin. If this is the case then simply configure the
- // mojos the user has specified and ignore the rest.
- // ----------------------------------------------------------------------
+ processGoalContainerPhases( plugin, null, pluginDescriptor, session, plugin.getGoalsAsMap(), phaseMap,
+ goalInstanceMap );
- Map goalMap = plugin.getGoalsAsMap();
+ List executions = plugin.getExecutions();
- if ( pluginDescriptor.getMojos() != null )
+ if ( executions != null )
{
- for ( Iterator j = pluginDescriptor.getMojos().iterator(); j.hasNext(); )
+ for ( Iterator it = executions.iterator(); it.hasNext(); )
{
- MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
+ PluginExecution execution = (PluginExecution) it.next();
- // TODO: remove later
- if ( mojoDescriptor.getGoal() == null )
+ if ( execution.isInheritanceApplied() )
{
- throw new LifecycleExecutionException(
- "The plugin " + artifactId + " was built with an older version of Maven" );
+ processGoalContainerPhases( plugin, execution, pluginDescriptor, session, execution
+ .getGoalsAsMap(), phaseMap, goalInstanceMap );
}
+ }
+ }
+ }
+ }
+
+ private void processGoalContainerPhases( Plugin plugin, PluginExecution execution,
+ PluginDescriptor pluginDescriptor, MavenSession session, Map goalMap,
+ Map phaseMap, Map goalInstanceMap )
+ throws LifecycleExecutionException
+ {
+ // ----------------------------------------------------------------------
+ // Look to see if the plugin configuration specifies particular mojos
+ // within the plugin. If this is the case then simply configure the
+ // mojos the user has specified and ignore the rest.
+ // ----------------------------------------------------------------------
- Goal goal = (Goal) goalMap.get( mojoDescriptor.getGoal() );
+ if ( pluginDescriptor.getMojos() != null )
+ {
+ for ( Iterator j = pluginDescriptor.getMojos().iterator(); j.hasNext(); )
+ {
+ MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
- if ( goalMap.isEmpty() )
+ // TODO: remove later
+ if ( mojoDescriptor.getGoal() == null )
+ {
+ throw new LifecycleExecutionException( "The plugin " + pluginDescriptor.getId()
+ + " was built with an older version of Maven" );
+ }
+
+ Goal goal = (Goal) goalMap.get( mojoDescriptor.getGoal() );
+
+ if ( goalMap.isEmpty() )
+ {
+ configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() );
+
+ addToGoalInstanceMap( goalInstanceMap, new GoalInstance( plugin, execution, goal, mojoDescriptor ) );
+ }
+ else if ( goal != null )
+ {
+ // We have to check to see that the inheritance rules have been applied before binding this mojo.
+ if ( goal.isInheritanceApplied() || mojoDescriptor.isInheritedByDefault() )
{
configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() );
- }
- else if ( goal != null )
- {
- // We have to check to see that the inheritance rules have been applied before binding this mojo.
- if ( goal.isInheritanceApplied() || mojoDescriptor.isInheritedByDefault() )
- {
- configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() );
- }
+
+ addToGoalInstanceMap( goalInstanceMap, new GoalInstance( plugin, execution, goal,
+ mojoDescriptor ) );
}
}
}
@@ -301,17 +406,27 @@
{
if ( mojoDescriptor.getPhase() != null )
{
- List goals = (List) phaseMap.get( mojoDescriptor.getPhase() );
+ addToPhaseMap( phaseMap, mojoDescriptor.getPhase(), mojoDescriptor );
+ }
+ }
+ }
- if ( goals == null )
- {
- String message = "Required phase '" + mojoDescriptor.getPhase() + "' not found";
- throw new LifecycleExecutionException( message );
- }
- if ( !goals.contains( mojoDescriptor.getId() ) )
- {
- goals.add( mojoDescriptor.getId() );
- }
+ private void addToPhaseMap( Map phaseMap, String phase, MojoDescriptor mojoDescriptor )
+ throws LifecycleExecutionException
+ {
+ if ( phase != null )
+ {
+ List goals = (List) phaseMap.get( phase );
+
+ if ( goals == null )
+ {
+ String message = "Required phase '" + phase + "' not found";
+ throw new LifecycleExecutionException( message );
+ }
+
+ if ( !goals.contains( mojoDescriptor ) )
+ {
+ goals.add( mojoDescriptor );
}
}
}
@@ -334,20 +449,17 @@
if ( phaseGoals != null )
{
- for ( Iterator k = phaseGoals.iterator(); k.hasNext(); )
- {
- String goal = (String) k.next();
-
- goals.add( configureMojo( goal, session, phaseMap ) );
-
- }
+ goals.addAll( phaseGoals );
}
}
}
else
{
- goals.add( configureMojo( task, session, phaseMap ) );
+ MojoDescriptor mojoDescriptor = configureMojo( task, session, phaseMap );
+
+ goals.add( mojoDescriptor );
}
+
return goals;
}
@@ -361,6 +473,61 @@
return mojoDescriptor;
}
+ private List findMatchingGoalInstances( MojoDescriptor mojoDescriptor, MavenProject project )
+ {
+ PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
+
+ List plugins = project.getBuildPlugins();
+
+ List matchingSteps = new ArrayList();
+
+ Plugin plugin = null;
+
+ for ( Iterator it = plugins.iterator(); it.hasNext(); )
+ {
+ plugin = (Plugin) it.next();
+
+ if ( pluginDescriptor.getPluginLookupKey().equals( plugin.getKey() ) )
+ {
+ String mojoGoal = mojoDescriptor.getGoal();
+
+ Goal unattached = (Goal) plugin.getGoalsAsMap().get( mojoDescriptor.getGoal() );
+
+ if ( unattached != null )
+ {
+ matchingSteps.add( new GoalInstance( plugin, unattached, mojoDescriptor ) );
+ }
+
+ List executions = plugin.getExecutions();
+
+ if ( executions != null )
+ {
+ for ( Iterator executionIterator = executions.iterator(); executionIterator.hasNext(); )
+ {
+ PluginExecution execution = (PluginExecution) executionIterator.next();
+
+ Goal attached = (Goal) execution.getGoalsAsMap().get( mojoDescriptor.getGoal() );
+
+ if ( attached != null )
+ {
+ matchingSteps.add( new GoalInstance( plugin, execution, attached, mojoDescriptor ) );
+ }
+ }
+ }
+
+ break;
+ }
+ }
+
+ // if nothing is configured, then we need to add a "fully detached" step...
+ if ( matchingSteps.isEmpty() )
+ {
+ matchingSteps.add( new GoalInstance( mojoDescriptor ) );
+ }
+
+ return matchingSteps;
+ }
+
private MojoDescriptor getMojoDescriptor( String task, MavenSession session )
throws ArtifactResolutionException, LifecycleExecutionException
{
@@ -395,8 +562,8 @@
}
else
{
- String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" +
- " a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
+ String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or"
+ + " a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
throw new LifecycleExecutionException( message );
}
@@ -416,8 +583,8 @@
}
else
{
- injectHandlerPluginConfiguration( session.getProject(), pluginDescriptor.getGroupId(),
- pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion() );
+ injectHandlerPluginConfiguration( session.getProject(), pluginDescriptor.getGroupId(), pluginDescriptor
+ .getArtifactId(), pluginDescriptor.getVersion() );
}
MojoDescriptor mojoDescriptor = null;
@@ -436,10 +603,9 @@
}
else
{
- throw new LifecycleExecutionException( "The plugin " + pluginDescriptor.getGroupId() + ":" +
- pluginDescriptor.getArtifactId() + ":" +
- pluginDescriptor.getVersion() +
- " doesn't contain any mojo. Check if it isn't corrupted." );
+ throw new LifecycleExecutionException( "The plugin " + pluginDescriptor.getGroupId() + ":"
+ + pluginDescriptor.getArtifactId() + ":" + pluginDescriptor.getVersion()
+ + " doesn't contain any mojo. Check if it isn't corrupted." );
}
if ( mojoDescriptor == null )
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Sun Jun 12 19:47:57 2005
@@ -116,7 +116,7 @@
{
PluginDescriptor pluginDescriptor = (PluginDescriptor) componentSetDescriptor;
-// String key = pluginDescriptor.getId();
+ // String key = pluginDescriptor.getId();
// TODO: see comment in getPluginDescriptor
String key = pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId();
@@ -141,7 +141,7 @@
private PluginDescriptor getPluginDescriptor( String groupId, String artifactId, String version )
{
-// String key = PluginDescriptor.constructPluginKey( groupId, artifactId, version );
+ // String key = PluginDescriptor.constructPluginKey( groupId, artifactId, version );
// TODO: include version, but can't do this in the plugin manager as it is not resolved to the right version
// at that point. Instead, move the duplication check to the artifact container, or store it locally based on
// the unresolved version?
@@ -156,7 +156,7 @@
private boolean isPluginInstalled( String pluginKey )
{
-// String key = PluginDescriptor.constructPluginKey( groupId, artifactId, version );
+ // String key = PluginDescriptor.constructPluginKey( groupId, artifactId, version );
// TODO: see comment in getPluginDescriptor
return pluginDescriptors.containsKey( pluginKey );
}
@@ -176,7 +176,7 @@
}
public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project,
- ArtifactRepository localRepository )
+ ArtifactRepository localRepository )
throws ArtifactResolutionException, PluginManagerException
{
@@ -243,13 +243,14 @@
}
catch ( PlexusContainerException e )
{
- throw new PluginManagerException( "Error occurred in the artifact container attempting to download plugin " +
- groupId + ":" + artifactId, e );
+ throw new PluginManagerException(
+ "Error occurred in the artifact container attempting to download plugin "
+ + groupId + ":" + artifactId, e );
}
catch ( ArtifactResolutionException e )
{
- if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
- version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) )
+ if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() )
+ && version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) )
{
throw new PluginNotFoundException( e );
}
@@ -260,15 +261,15 @@
}
catch ( ComponentLookupException e )
{
- throw new PluginManagerException( "Internal configuration error while retrieving " + groupId + ":" +
- artifactId, e );
+ throw new PluginManagerException( "Internal configuration error while retrieving " + groupId + ":"
+ + artifactId, e );
}
}
return getPluginDescriptor( groupId, artifactId, version );
}
protected void addPlugin( String pluginKey, Artifact pluginArtifact, MavenProject project,
- ArtifactRepository localRepository )
+ ArtifactRepository localRepository )
throws ArtifactResolutionException, ComponentLookupException, PlexusContainerException
{
ArtifactResolver artifactResolver = null;
@@ -282,9 +283,9 @@
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
- ArtifactResolutionResult result = artifactResolver.resolveTransitively(
- Collections.singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository,
- metadataSource, artifactFilter );
+ ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections
+ .singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository, metadataSource,
+ artifactFilter );
Map resolved = result.getArtifacts();
@@ -328,11 +329,13 @@
// Mojo execution
// ----------------------------------------------------------------------
- public void executeMojo( MavenSession session, MojoDescriptor mojoDescriptor )
+ public void executeMojo( MavenSession session, GoalInstance goalInstance )
throws ArtifactResolutionException, PluginManagerException, MojoExecutionException
{
PlexusContainer pluginContainer = null;
+ MojoDescriptor mojoDescriptor = goalInstance.getMojoDescriptor();
+
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
{
@@ -344,8 +347,8 @@
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE );
- resolveTransitiveDependencies( session, artifactResolver, mavenProjectBuilder,
- mojoDescriptor.isDependencyResolutionRequired() );
+ resolveTransitiveDependencies( session, artifactResolver, mavenProjectBuilder, mojoDescriptor
+ .isDependencyResolutionRequired() );
downloadDependencies( session, artifactResolver );
}
catch ( ComponentLookupException e )
@@ -383,11 +386,11 @@
plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
plugin.setLog( mojoLogger );
- String goalId = mojoDescriptor.getGoal();
+ String goalId = goalInstance.getGoalId();
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
- Xpp3Dom dom = session.getProject().getGoalConfiguration( pluginDescriptor.getGroupId(),
- pluginDescriptor.getArtifactId(), goalId );
+
+ Xpp3Dom dom = goalInstance.getCalculatedConfiguration();
PlexusConfiguration pomConfiguration;
if ( dom == null )
@@ -403,12 +406,12 @@
// override in the POM.
validatePomConfiguration( mojoDescriptor, pomConfiguration );
- PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
- mojoDescriptor.getMojoConfiguration() );
-
+ PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration, mojoDescriptor
+ .getMojoConfiguration() );
+
// TODO: plexus
-// PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
-// mojoDescriptor.getConfiguration() );
+ // PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
+ // mojoDescriptor.getConfiguration() );
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, pathTranslator,
getLogger() );
@@ -420,17 +423,25 @@
// Event monitoring.
String event = MavenEvents.MOJO_EXECUTION;
EventDispatcher dispatcher = session.getEventDispatcher();
+
+ String goalExecId = goalName;
+
+ if ( goalInstance.getExecutionId() != null )
+ {
+ goalExecId += " {execution: " + goalInstance.getExecutionId() + "}";
+ }
- dispatcher.dispatchStart( event, goalName );
+ dispatcher.dispatchStart( event, goalExecId );
try
{
plugin.execute();
- dispatcher.dispatchEnd( event, goalName );
+ dispatcher.dispatchEnd( event, goalExecId );
}
catch ( MojoExecutionException e )
{
- session.getEventDispatcher().dispatchError( event, goalName, e );
+ session.getEventDispatcher().dispatchError( event, goalExecId, e );
+
throw e;
}
// End event monitoring.
@@ -462,7 +473,7 @@
}
private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration,
- ExpressionEvaluator expressionEvaluator, Mojo plugin )
+ ExpressionEvaluator expressionEvaluator, Mojo plugin )
throws PluginConfigurationException
{
// TODO: this should be built in to the configurator, as we presently double process the expressions
@@ -534,8 +545,9 @@
}
if ( fieldValue != null )
{
- getLogger().warn( "DEPRECATED: using default-value to set the default value of field '" +
- parameter.getName() + "'" );
+ getLogger().warn(
+ "DEPRECATED: using default-value to set the default value of field '"
+ + parameter.getName() + "'" );
}
}
catch ( NoSuchFieldException e )
@@ -587,8 +599,8 @@
// Make sure the parameter is either editable/configurable, or else is NOT specified in the POM
if ( !parameter.isEditable() )
{
- StringBuffer errorMessage = new StringBuffer().append(
- "ERROR: Cannot override read-only parameter: " );
+ StringBuffer errorMessage = new StringBuffer()
+ .append( "ERROR: Cannot override read-only parameter: " );
errorMessage.append( key );
errorMessage.append( " in goal: " ).append( goal.getFullGoalName() );
@@ -651,7 +663,7 @@
// ----------------------------------------------------------------------
private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
- PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
+ PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
throws PluginConfigurationException
{
ComponentConfigurator configurator = null;
@@ -663,16 +675,16 @@
// TODO: should this be known to the component factory instead? And if so, should configuration be part of lookup?
if ( StringUtils.isNotEmpty( configuratorId ) )
{
- configurator =
- (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId );
+ configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE,
+ configuratorId );
}
else
{
configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE );
}
- configurator.configureComponent( plugin, configuration, expressionEvaluator,
- pluginContainer.getContainerRealm() );
+ configurator.configureComponent( plugin, configuration, expressionEvaluator, pluginContainer
+ .getContainerRealm() );
}
catch ( ComponentConfigurationException e )
{
@@ -681,7 +693,8 @@
catch ( ComponentLookupException e )
{
throw new PluginConfigurationException(
- "Unable to retrieve component configurator for plugin configuration", e );
+ "Unable to retrieve component configurator for plugin configuration",
+ e );
}
finally
{
@@ -720,7 +733,7 @@
}
public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter,
- String expression )
+ String expression )
{
StringBuffer message = new StringBuffer();
@@ -776,12 +789,22 @@
public void initialize()
{
// TODO: configure this from bootstrap or scan lib
- artifactFilter = new ExclusionSetFilter( new String[]{"classworlds", "maven-artifact", "maven-core",
- "maven-model", "maven-monitor", "maven-plugin-api",
- "maven-plugin-descriptor", "maven-project",
- "maven-settings", "plexus-container-default",
- "plexus-utils", "wagon-provider-api", "wagon-ssh",
- "wagon-http-lightweight", "wagon-file"} );
+ artifactFilter = new ExclusionSetFilter( new String[] {
+ "classworlds",
+ "maven-artifact",
+ "maven-core",
+ "maven-model",
+ "maven-monitor",
+ "maven-plugin-api",
+ "maven-plugin-descriptor",
+ "maven-project",
+ "maven-settings",
+ "plexus-container-default",
+ "plexus-utils",
+ "wagon-provider-api",
+ "wagon-ssh",
+ "wagon-http-lightweight",
+ "wagon-file" } );
}
// ----------------------------------------------------------------------
@@ -789,7 +812,7 @@
// ----------------------------------------------------------------------
private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver,
- MavenProjectBuilder mavenProjectBuilder, String scope )
+ MavenProjectBuilder mavenProjectBuilder, String scope )
throws ArtifactResolutionException
{
MavenProject project = context.getProject();
@@ -800,10 +823,8 @@
boolean systemOnline = !context.getSettings().isOffline();
- ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
- context.getRemoteRepositories(),
- context.getLocalRepository(),
- sourceReader, filter );
+ ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(), context
+ .getRemoteRepositories(), context.getLocalRepository(), sourceReader, filter );
project.addArtifacts( result.getArtifacts().values(), artifactFactory );
}
@@ -834,8 +855,8 @@
}
context.getProject().setPluginArtifacts( pluginArtifacts );
- artifactResolver.resolve( context.getProject().getParentArtifact(), context.getRemoteRepositories(),
- context.getLocalRepository() );
+ artifactResolver.resolve( context.getProject().getParentArtifact(), context.getRemoteRepositories(), context
+ .getLocalRepository() );
}
}
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/GoalInstance.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/GoalInstance.java?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/GoalInstance.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/GoalInstance.java Sun Jun 12 19:47:57 2005
@@ -0,0 +1,205 @@
+package org.apache.maven.plugin;
+
+import org.apache.maven.model.Goal;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public class GoalInstance
+{
+
+ private final MojoDescriptor mojoDescriptor;
+
+ private String pluginKey;
+
+ private String executionId;
+
+ private Xpp3Dom calculatedConfiguration;
+
+ public GoalInstance( Plugin plugin, PluginExecution pluginExecution, Goal goal, MojoDescriptor mojoDescriptor )
+ {
+ if ( plugin != null )
+ {
+ this.pluginKey = plugin.getKey();
+ }
+
+ if ( pluginExecution != null )
+ {
+ this.executionId = pluginExecution.getId();
+ }
+
+ this.mojoDescriptor = mojoDescriptor;
+
+ calculateConfiguration( plugin, pluginExecution, goal );
+ }
+
+ public GoalInstance( Plugin plugin, Goal goal, MojoDescriptor mojoDescriptor )
+ {
+ this( plugin, null, goal, mojoDescriptor );
+ }
+
+ public GoalInstance( MojoDescriptor mojoDescriptor )
+ {
+ this( null, null, null, mojoDescriptor );
+ }
+
+ public MojoDescriptor getMojoDescriptor()
+ {
+ return mojoDescriptor;
+ }
+
+ public String getMojoExecutePhase()
+ {
+ return mojoDescriptor.getExecutePhase();
+ }
+
+ public String getPluginKey()
+ {
+ return pluginKey;
+ }
+
+ public String getExecutionId()
+ {
+ return executionId;
+ }
+
+ public String getGoalId()
+ {
+ return mojoDescriptor.getGoal();
+ }
+
+ public Xpp3Dom calculateConfiguration( Plugin plugin, PluginExecution pluginExecution, Goal goal )
+ {
+ calculatedConfiguration = new Xpp3Dom( "configuration" );
+
+ if ( plugin != null )
+ {
+ Xpp3Dom pluginConfig = (Xpp3Dom) plugin.getConfiguration();
+
+ if ( pluginConfig != null )
+ {
+ calculatedConfiguration = Xpp3Dom.mergeXpp3Dom( pluginConfig, calculatedConfiguration );
+ }
+ }
+
+ if ( pluginExecution != null )
+ {
+ Xpp3Dom executionConfig = (Xpp3Dom) pluginExecution.getConfiguration();
+
+ if ( executionConfig != null )
+ {
+ calculatedConfiguration = Xpp3Dom.mergeXpp3Dom( executionConfig, calculatedConfiguration );
+ }
+ }
+
+ if ( goal != null )
+ {
+ Xpp3Dom goalConfig = (Xpp3Dom) goal.getConfiguration();
+
+ if ( goalConfig != null )
+ {
+ calculatedConfiguration = Xpp3Dom.mergeXpp3Dom( goalConfig, calculatedConfiguration );
+ }
+ }
+
+ calculatedConfiguration = new Xpp3Dom( calculatedConfiguration );
+
+ return calculatedConfiguration;
+ }
+
+ public boolean equals( Object object )
+ {
+ if ( object == this )
+ {
+ return true;
+ }
+
+ if ( object instanceof GoalInstance )
+ {
+ GoalInstance other = (GoalInstance) object;
+
+ if ( !getMojoDescriptor().equals( other.getMojoDescriptor() ) )
+ {
+ return false;
+ }
+
+ String execId = getExecutionId();
+
+ String otherExecId = other.getExecutionId();
+
+ if ( execId == otherExecId )
+ {
+ return true;
+ }
+
+ if ( execId == null && otherExecId != null )
+ {
+ return false;
+ }
+
+ if ( execId != null && otherExecId == null )
+ {
+ return false;
+ }
+
+ return execId.equals( otherExecId );
+ }
+
+ return false;
+ }
+
+ public int hashCode()
+ {
+ int result = 2;
+
+ // this should NEVER be null...
+ result += getMojoDescriptor().hashCode();
+
+ String execId = getExecutionId();
+
+ if ( execId != null )
+ {
+ result -= execId.hashCode();
+ }
+
+ return result;
+ }
+
+ public String toString()
+ {
+ return "goal instance {goal: " + getGoalId() + ", execution-id: " + getExecutionId() + "}";
+ }
+
+ public Xpp3Dom getCalculatedConfiguration()
+ {
+ return new Xpp3Dom( calculatedConfiguration );
+ }
+
+ public void incorporate( GoalInstance other )
+ {
+ Xpp3Dom otherConfig = (Xpp3Dom) other.getCalculatedConfiguration();
+
+ if ( otherConfig != null )
+ {
+ calculatedConfiguration = new Xpp3Dom( Xpp3Dom.mergeXpp3Dom( otherConfig, calculatedConfiguration ) );
+ }
+ }
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/GoalInstance.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java Sun Jun 12 19:47:57 2005
@@ -19,7 +19,6 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
@@ -31,7 +30,7 @@
{
String ROLE = PluginManager.class.getName();
- void executeMojo( MavenSession session, MojoDescriptor mojoDescriptor )
+ void executeMojo( MavenSession session, GoalInstance buildStep )
throws MojoExecutionException, PluginManagerException, ArtifactResolutionException;
PluginDescriptor verifyPlugin( String prefix );
Modified: maven/components/trunk/maven-model/maven.mdo
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/maven.mdo?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-model/maven.mdo (original)
+++ maven/components/trunk/maven-model/maven.mdo Sun Jun 12 19:47:57 2005
@@ -2081,32 +2081,13 @@
-->
<class>
- <name>Plugin</name>
+ <name>GoalContainer</name>
<version>4.0.0</version>
<fields>
<field>
- <name>groupId</name>
- <version>4.0.0</version>
- <type>String</type>
- <defaultValue>org.apache.maven.plugins</defaultValue>
- </field>
- <field>
- <name>artifactId</name>
- <version>4.0.0</version>
- <type>String</type>
- <required>true</required>
- </field>
- <field>
- <name>version</name>
- <version>4.0.0</version>
- <required>true</required>
- <description><![CDATA[The version of the plugin to be used.]]></description>
- <type>String</type>
- </field>
- <field>
<name>inherited</name>
<version>4.0.0</version>
- <description><![CDATA[Whether this plugin configuration should be propagated to child POMs.]]></description>
+ <description><![CDATA[Whether this container's configuration should be propagated to child POMs.]]></description>
<type>String</type>
</field>
<field>
@@ -2131,7 +2112,7 @@
public void unsetInheritanceApplied()
{
- this.inheritanceApplied = true;
+ this.inheritanceApplied = false;
}
public boolean isInheritanceApplied()
@@ -2160,7 +2141,73 @@
}
return goalMap;
}
+ ]]></code>
+ </codeSegment>
+ </codeSegments>
+ </class>
+ <class>
+ <name>Plugin</name>
+ <version>4.0.0</version>
+ <superClass>GoalContainer</superClass>
+ <fields>
+ <field>
+ <name>groupId</name>
+ <version>4.0.0</version>
+ <type>String</type>
+ <defaultValue>org.apache.maven.plugins</defaultValue>
+ </field>
+ <field>
+ <name>artifactId</name>
+ <version>4.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ </field>
+ <field>
+ <name>version</name>
+ <version>4.0.0</version>
+ <required>true</required>
+ <description><![CDATA[The version of the plugin to be used.]]></description>
+ <type>String</type>
+ </field>
+ <field>
+ <name>executions</name>
+ <version>4.0.0</version>
+ <description>Multiple specifications of a set of goals, each having (possibly) different configuration</description>
+ <association>
+ <type>PluginExecution</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ </field>
+ </fields>
+ <codeSegments>
+ <codeSegment>
+ <version>4.0.0</version>
+ <code><![CDATA[
+ private Map executionMap = null;
+
+ public void flushExecutionMap()
+ {
+ this.executionMap = null;
+ }
+ public Map getExecutionsAsMap()
+ {
+ if ( executionMap == null )
+ {
+ executionMap = new HashMap();
+ if ( getExecutions() != null )
+ {
+ for ( Iterator i = getExecutions().iterator(); i.hasNext(); )
+ {
+ PluginExecution exec = (PluginExecution) i.next();
+ executionMap.put( exec.getId(), exec );
+ }
+ }
+ }
+
+ return executionMap;
+ }
+
public String getKey()
{
return constructKey( groupId, artifactId );
@@ -2175,6 +2222,19 @@
</codeSegments>
</class>
<class>
+ <name>PluginExecution</name>
+ <version>4.0.0</version>
+ <superClass>GoalContainer</superClass>
+ <fields>
+ <field>
+ <name>id</name>
+ <version>4.0.0</version>
+ <required>true</required>
+ <type>String</type>
+ </field>
+ </fields>
+ </class>
+ <class>
<name>Goal</name>
<version>4.0.0</version>
<fields>
@@ -2201,7 +2261,7 @@
public void unsetInheritanceApplied()
{
- this.inheritanceApplied = true;
+ this.inheritanceApplied = false;
}
public boolean isInheritanceApplied()
Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java (original)
+++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java Sun Jun 12 19:47:57 2005
@@ -60,7 +60,7 @@
private String executePhase;
private String deprecated;
-
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -121,7 +121,7 @@
addParameter( parameter );
}
}
-
+
public void addParameter( Parameter parameter )
throws DuplicateParameterException
{
@@ -311,5 +311,68 @@
public void setInheritedByDefault( boolean inheritedByDefault )
{
this.inheritedByDefault = inheritedByDefault;
+ }
+
+ public boolean equals( Object object )
+ {
+ if ( this == object )
+ {
+ return true;
+ }
+
+ if ( object instanceof MojoDescriptor )
+ {
+ MojoDescriptor other = (MojoDescriptor) object;
+
+ if ( !compareObjects( getPluginDescriptor(), other.getPluginDescriptor() ) )
+ {
+ return false;
+ }
+
+ if ( !compareObjects( getGoal(), other.getGoal() ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private boolean compareObjects( Object first, Object second )
+ {
+ if ( ( first == null && second != null ) || ( first != null && second == null ) )
+ {
+ return false;
+ }
+
+ if ( !first.equals( second ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result = 1;
+
+ String goal = getGoal();
+
+ if ( goal != null )
+ {
+ result += goal.hashCode();
+ }
+
+ PluginDescriptor pd = getPluginDescriptor();
+
+ if ( pd != null )
+ {
+ result -= pd.hashCode();
+ }
+
+ return result;
}
}
Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java (original)
+++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Sun Jun 12 19:47:57 2005
@@ -64,7 +64,8 @@
MojoDescriptor existing = (MojoDescriptor) mojos.get( indexOf );
- throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing.getImplementation(), mojoDescriptor.getImplementation() );
+ throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing
+ .getImplementation(), mojoDescriptor.getImplementation() );
}
else
{
@@ -100,12 +101,12 @@
{
return groupId + ":" + artifactId + ":" + version;
}
-
+
public String getPluginLookupKey()
{
return groupId + ":" + artifactId;
}
-
+
public String getId()
{
String id = constructPluginKey( groupId, artifactId, version );
@@ -187,5 +188,20 @@
public void setInheritedByDefault( boolean inheritedByDefault )
{
this.inheritedByDefault = inheritedByDefault;
+ }
+
+ public boolean equals( Object object )
+ {
+ if ( this == object )
+ {
+ return true;
+ }
+
+ return getId().equals( ( (PluginDescriptor) object ).getId() );
+ }
+
+ public int hashCode()
+ {
+ return 10 + getId().hashCode();
}
}
Modified: maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java Sun Jun 12 19:47:57 2005
@@ -20,6 +20,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id$
* @goal compile
+ * @phase compile
* @requiresDependencyResolution compile
* @description Compiles application sources
* @todo change debug parameter type to Boolean
Modified: maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java Sun Jun 12 19:47:57 2005
@@ -22,6 +22,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @goal testCompile
+ * @phase test-compile
* @description Compiles test sources
* @requiresDependencyResolution test
*/
Modified: maven/components/trunk/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java Sun Jun 12 19:47:57 2005
@@ -35,6 +35,7 @@
* @author <a href="mailto:jdcasey@apache.org">John Casey (refactoring only)</a>
* @version $Id$
* @goal deploy
+ * @phase deploy
*/
public class DeployMojo
extends AbstractMojo
Modified: maven/components/trunk/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java Sun Jun 12 19:47:57 2005
@@ -31,6 +31,7 @@
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
* @goal install
+ * @phase install
*/
public class InstallMojo
extends AbstractInstallMojo
Modified: maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java Sun Jun 12 19:47:57 2005
@@ -29,6 +29,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @goal descriptor
+ * @phase generate-resources
*/
public class DescriptorGeneratorMojo
extends AbstractGeneratorMojo
Modified: maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java Sun Jun 12 19:47:57 2005
@@ -34,6 +34,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @goal resources
+ * @phase process-resources
* @description copy application resources
*/
public class ResourcesMojo
Modified: maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/TestResourcesMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/TestResourcesMojo.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/TestResourcesMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/TestResourcesMojo.java Sun Jun 12 19:47:57 2005
@@ -25,6 +25,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @goal testResources
+ * @phase process-test-resources
* @description copy test resources
*/
public class TestResourcesMojo
Modified: maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java (original)
+++ maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java Sun Jun 12 19:47:57 2005
@@ -37,6 +37,7 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
* @goal test
+ * @phase test
* @description Run tests using surefire
* @todo make version of junit and surefire configurable
* @todo make report to be produced configurable
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=190335&r1=190334&r2=190335&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Sun Jun 12 19:47:57 2005
@@ -1,8 +1,10 @@
package org.apache.maven.project;
import org.apache.maven.model.Goal;
+import org.apache.maven.model.GoalContainer;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginContainer;
+import org.apache.maven.model.PluginExecution;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.ArrayList;
@@ -33,12 +35,12 @@
public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer,
boolean handleAsInheritance )
{
- if( childContainer == null || parentContainer == null )
+ if ( childContainer == null || parentContainer == null )
{
// nothing to do.
return;
}
-
+
List parentPlugins = parentContainer.getPlugins();
if ( parentPlugins != null && !parentPlugins.isEmpty() )
@@ -50,13 +52,13 @@
for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
{
Plugin parentPlugin = (Plugin) it.next();
-
+
String parentInherited = parentPlugin.getInherited();
if ( !handleAsInheritance || parentInherited == null
|| Boolean.valueOf( parentInherited ).booleanValue() )
{
-
+
Plugin assembledPlugin = parentPlugin;
Plugin childPlugin = (Plugin) childPlugins.get( parentPlugin.getKey() );
@@ -88,24 +90,87 @@
}
childContainer.setPlugins( new ArrayList( assembledPlugins.values() ) );
-
+
childContainer.flushPluginMap();
}
}
public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance )
{
- if( child == null || parent == null )
+ if ( child == null || parent == null )
{
// nothing to do.
return;
}
-
+
if ( child.getVersion() == null && parent.getVersion() != null )
{
child.setVersion( parent.getVersion() );
}
+ // merge the lists of goals that are not attached to an <execution/>
+ ModelUtils.mergeGoalContainerDefinitions( child, parent, handleAsInheritance );
+
+ // from here to the end of the method is dealing with merging of the <executions/> section.
+ String parentInherited = parent.getInherited();
+
+ boolean parentIsInherited = parentInherited == null || Boolean.valueOf( parentInherited ).booleanValue();
+
+ List parentExecutions = parent.getExecutions();
+
+ if ( parentExecutions != null && !parentExecutions.isEmpty() )
+ {
+ Map assembledExecutions = new TreeMap();
+
+ Map childExecutions = child.getExecutionsAsMap();
+
+ for ( Iterator it = parentExecutions.iterator(); it.hasNext(); )
+ {
+ PluginExecution parentExecution = (PluginExecution) it.next();
+
+ if ( !handleAsInheritance || parentIsInherited )
+ {
+ PluginExecution assembled = parentExecution;
+
+ PluginExecution childExecution = (PluginExecution) childExecutions.get( parentExecution.getId() );
+
+ if ( childExecution != null )
+ {
+ ModelUtils.mergeGoalContainerDefinitions( childExecution, parentExecution, handleAsInheritance );
+
+ assembled = childExecution;
+ }
+ else if ( handleAsInheritance && parentInherited == null )
+ {
+ parentExecution.unsetInheritanceApplied();
+ }
+
+ assembledExecutions.put( assembled.getId(), assembled );
+ }
+ }
+
+ for ( Iterator it = childExecutions.entrySet().iterator(); it.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+
+ String id = (String) entry.getKey();
+
+ if ( !assembledExecutions.containsKey( id ) )
+ {
+ assembledExecutions.put( id, entry.getValue() );
+ }
+ }
+
+ child.setExecutions( new ArrayList( assembledExecutions.values() ) );
+
+ child.flushExecutionMap();
+ }
+
+ }
+
+ private static void mergeGoalContainerDefinitions( GoalContainer child, GoalContainer parent,
+ boolean handleAsInheritance )
+ {
List parentGoals = parent.getGoals();
// if the supplemental goals are non-existent, then nothing related to goals changes.
@@ -141,8 +206,7 @@
assembledGoal = childGoal;
}
-
- if ( handleAsInheritance && parentInherited == null )
+ else if ( handleAsInheritance && parentInherited == null )
{
assembledGoal.unsetInheritanceApplied();
}
Added: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java?rev=190335&view=auto
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java (added)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java Sun Jun 12 19:47:57 2005
@@ -0,0 +1,100 @@
+package org.apache.maven.project;
+
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
+
+import junit.framework.TestCase;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+public class ModelUtilsTest
+ extends TestCase
+{
+
+ public void testShouldInheritOnePluginWithExecution()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ ModelUtils.mergePluginDefinitions( child, parent, false );
+
+ assertEquals( 1, child.getExecutions().size() );
+ }
+
+ public void testShouldMergeInheritedPluginHavingExecutionWithLocalPlugin()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ PluginExecution childExecution = new PluginExecution();
+ childExecution.setId( "testExecution2" );
+
+ child.addExecution( childExecution );
+
+ ModelUtils.mergePluginDefinitions( child, parent, false );
+
+ assertEquals( 2, child.getExecutions().size() );
+ }
+
+ public void testShouldNOTMergeInheritedPluginHavingInheritEqualFalse()
+ {
+ Plugin parent = new Plugin();
+ parent.setArtifactId( "testArtifact" );
+ parent.setGroupId( "testGroup" );
+ parent.setVersion( "1.0" );
+ parent.setInherited( "false" );
+
+ PluginExecution parentExecution = new PluginExecution();
+ parentExecution.setId( "testExecution" );
+
+ parent.addExecution( parentExecution );
+
+ Plugin child = new Plugin();
+ child.setArtifactId( "testArtifact" );
+ child.setGroupId( "testGroup" );
+ child.setVersion( "1.0" );
+
+ ModelUtils.mergePluginDefinitions( child, parent, true );
+
+ assertEquals( 0, child.getExecutions().size() );
+ }
+
+}
Propchange: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org