mirror of
https://github.com/apache/maven.git
synced 2025-02-08 11:05:37 +00:00
o adding capability to the lifecycle executor to merge in executions which contain
configurations for external plugins. in this particular i've made the adjustments so that the corbertura plugin can tell the surefire plugin to fork. not ideal, but it will work until we figure out a more elegant solution. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@356065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b9c5816ba9
commit
db17a2494b
@ -57,6 +57,7 @@
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -780,11 +781,67 @@ private void forkProjectLifecycle( MojoDescriptor mojoDescriptor, Stack forkEntr
|
||||
for ( Iterator k = e.getGoals().iterator(); k.hasNext(); )
|
||||
{
|
||||
String goal = (String) k.next();
|
||||
MojoDescriptor desc = getMojoDescriptor( pluginDescriptor, goal );
|
||||
|
||||
PluginDescriptor lifecyclePluginDescriptor;
|
||||
String lifecycleGoal;
|
||||
|
||||
// Here we are looking to see if we have a mojo from an external plugin.
|
||||
// If we do then we need to lookup the plugin descriptor for the externally
|
||||
// referenced plugin so that we can overly the execution into the lifecycle.
|
||||
// An example of this is the corbertura plugin that needs to call the surefire
|
||||
// plugin in forking mode.
|
||||
//
|
||||
//<phase>
|
||||
// <id>test</id>
|
||||
// <executions>
|
||||
// <execution>
|
||||
// <goals>
|
||||
// <goal>org.apache.maven.plugins:maven-surefire-plugin:test</goal>
|
||||
// </goals>
|
||||
// <configuration>
|
||||
// <classesDirectory>${project.build.directory}/generated-classes/cobertura</classesDirectory>
|
||||
// <ignoreFailures>true</ignoreFailures>
|
||||
// <forkMode>once</forkMode>
|
||||
// </configuration>
|
||||
// </execution>
|
||||
// </executions>
|
||||
//</phase>
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
if ( goal.indexOf( ":" ) > 0 )
|
||||
{
|
||||
String[] s = StringUtils.split( goal, ":" );
|
||||
|
||||
String groupId = s[0];
|
||||
String artifactId = s[1];
|
||||
String externalGoal = s[2];
|
||||
lifecycleGoal = externalGoal;
|
||||
|
||||
try
|
||||
{
|
||||
lifecyclePluginDescriptor = pluginManager.getPluginDescriptor( groupId,
|
||||
artifactId,
|
||||
project,
|
||||
session.getSettings(),
|
||||
session.getLocalRepository() );
|
||||
}
|
||||
catch ( Exception ex )
|
||||
{
|
||||
throw new LifecycleExecutionException( ex );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lifecyclePluginDescriptor = pluginDescriptor;
|
||||
lifecycleGoal = goal;
|
||||
}
|
||||
|
||||
MojoDescriptor desc = getMojoDescriptor( lifecyclePluginDescriptor, lifecycleGoal );
|
||||
MojoExecution mojoExecution = new MojoExecution( desc, (Xpp3Dom) e.getConfiguration() );
|
||||
addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution,
|
||||
session.getSettings() );
|
||||
addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution, session.getSettings() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1230,8 +1287,7 @@ private void bindExecutionToLifecycle( PluginDescriptor pluginDescriptor, Map ph
|
||||
}
|
||||
}
|
||||
|
||||
private void addToLifecycleMappings( Map lifecycleMappings, String phase, MojoExecution mojoExecution,
|
||||
Settings settings )
|
||||
private void addToLifecycleMappings( Map lifecycleMappings, String phase, MojoExecution mojoExecution, Settings settings )
|
||||
{
|
||||
List goals = (List) lifecycleMappings.get( phase );
|
||||
|
||||
|
@ -137,6 +137,24 @@ public PluginDescriptor getPluginDescriptorForPrefix( String prefix )
|
||||
return pluginCollector.getPluginDescriptorForPrefix( prefix );
|
||||
}
|
||||
|
||||
public PluginDescriptor getPluginDescriptor( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
Plugin plugin = new Plugin();
|
||||
|
||||
plugin.setGroupId( groupId );
|
||||
|
||||
plugin.setArtifactId( artifactId );
|
||||
|
||||
String version = pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, settings, localRepository );
|
||||
|
||||
return pluginCollector.getPluginDescriptor( plugin );
|
||||
}
|
||||
|
||||
public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
|
||||
{
|
||||
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
|
||||
@ -240,7 +258,8 @@ else if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId
|
||||
* @todo would be better to store this in the plugin descriptor, but then it won't be available to the version
|
||||
* manager which executes before the plugin is instantiated
|
||||
*/
|
||||
private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
|
||||
private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List
|
||||
remoteRepositories )
|
||||
throws PluginVersionResolutionException, InvalidPluginException
|
||||
{
|
||||
try
|
||||
|
@ -52,6 +52,14 @@ MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenS
|
||||
|
||||
PluginDescriptor getPluginDescriptorForPrefix( String prefix );
|
||||
|
||||
PluginDescriptor getPluginDescriptor( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
|
||||
|
||||
|
||||
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project );
|
||||
|
||||
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||
|
Loading…
x
Reference in New Issue
Block a user