mirror of https://github.com/apache/maven.git
o slight lifecycle mixup with executions, temporary fix but the bootstrap works
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@771991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5ec5c90c89
commit
5d077ce8e5
|
@ -202,7 +202,7 @@ public class DefaultLifecycleExecutor
|
|||
logger.info( executionDescription( mojoExecution, project ) );
|
||||
// mojoExecution.getMojoDescriptor().getRealm().display();
|
||||
// System.out.println( "!!!");
|
||||
System.out.println( mojoExecution.getConfiguration() );
|
||||
// System.out.println( mojoExecution.getConfiguration() );
|
||||
pluginManager.executeMojo( session, mojoExecution );
|
||||
}
|
||||
catch ( PluginExecutionException e )
|
||||
|
@ -279,6 +279,9 @@ public class DefaultLifecycleExecutor
|
|||
Map<String,List<String>> phaseToMojoMapping = new LinkedHashMap<String,List<String>>();
|
||||
|
||||
// 4.
|
||||
|
||||
//TODO: need to separate the lifecycles
|
||||
|
||||
for ( String phase : lifecycle.getPhases() )
|
||||
{
|
||||
List<String> mojos = new ArrayList<String>();
|
||||
|
@ -294,18 +297,11 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
phaseToMojoMapping.put( phase, mojos );
|
||||
|
||||
// We only want to execute up to and including the specified lifecycle phase.
|
||||
if ( phase.equals( lifecyclePhase ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 5.
|
||||
// 5. Just build up the list of mojos that will execute for every phase.
|
||||
//
|
||||
// We are only interested in the phases that correspond to the lifecycle we are trying to run. If we are running the "clean"
|
||||
// lifecycle we are not interested in goals -- like "generate-sources -- that belong to the default lifecycle.
|
||||
// This will be useful for having the complete build plan and then we can filter/optimize later.
|
||||
//
|
||||
for( Plugin plugin : project.getBuild().getPlugins() )
|
||||
{
|
||||
|
@ -313,11 +309,22 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
// if the phase is specified then I don't have to go fetch the plugin yet and pull it down
|
||||
// to examine the phase it is associated to.
|
||||
if ( execution.getPhase() != null && execution.getPhase().equals( lifecyclePhase ) )
|
||||
if ( execution.getPhase() != null )
|
||||
{
|
||||
for( String goal : execution.getGoals() )
|
||||
{
|
||||
String s = plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() + ":" + goal;
|
||||
|
||||
if ( phaseToMojoMapping.get( execution.getPhase() ) == null )
|
||||
{
|
||||
// This is happening because executions in the POM are getting mixed into the clean lifecycle
|
||||
// So for the lifecycle mapping we need a map with the phases as keys so we can easily check
|
||||
// if this phase belongs to the given lifecycle. this shows the system is messed up. this
|
||||
// shouldn't happen.
|
||||
System.out.println( execution.getPhase() + "?????????????");
|
||||
phaseToMojoMapping.put( execution.getPhase(), new ArrayList<String>() );
|
||||
}
|
||||
|
||||
phaseToMojoMapping.get( execution.getPhase() ).add( s );
|
||||
}
|
||||
}
|
||||
|
@ -330,57 +337,77 @@ public class DefaultLifecycleExecutor
|
|||
String s = plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() + ":" + goal;
|
||||
MojoDescriptor md = getMojoDescriptor( s, session.getCurrentProject(), session.getLocalRepository() );
|
||||
|
||||
// need to know if this plugin belongs to a phase in the lifecycle that's running
|
||||
if ( md.getPhase() != null && phaseToMojoMapping.get( md.getPhase() ) != null )
|
||||
{
|
||||
phaseToMojoMapping.get( md.getPhase() ).add( s );
|
||||
}
|
||||
|
||||
//TODO Here we need to break when we have reached the desired phase.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 6.
|
||||
//
|
||||
// We are only interested in the phases that correspond to the lifecycle we are trying to run. If we are running the "clean"
|
||||
// lifecycle we are not interested in goals -- like "generate-sources -- that belong to the default lifecycle.
|
||||
//
|
||||
|
||||
// We only want to execute up to and including the specified lifecycle phase.
|
||||
// if ( phase.equals( lifecyclePhase ) )
|
||||
//{
|
||||
// break;
|
||||
//}
|
||||
|
||||
List<String> phasesWithMojosToExecute = new ArrayList<String>();
|
||||
|
||||
for( String phase : phaseToMojoMapping.keySet() )
|
||||
{
|
||||
phasesWithMojosToExecute.addAll( phaseToMojoMapping.get( phase ) );
|
||||
|
||||
if ( phase.equals( lifecyclePhase ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 7. Now we create the correct configuration for the mojo to execute.
|
||||
//TODO: this needs to go to the model builder.
|
||||
|
||||
List<MojoExecution> lifecyclePlan = new ArrayList<MojoExecution>();
|
||||
|
||||
// We need to turn this into a set of MojoExecutions
|
||||
for( List<String> mojos : phaseToMojoMapping.values() )
|
||||
for ( String mojo : phasesWithMojosToExecute )
|
||||
{
|
||||
for( String mojo : mojos )
|
||||
// These are bits that look like this:
|
||||
//
|
||||
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
|
||||
//
|
||||
MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, project, session.getLocalRepository() );
|
||||
|
||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
|
||||
|
||||
String g = mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId();
|
||||
|
||||
String a = mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId();
|
||||
|
||||
Plugin p = project.getPlugin( g + ":" + a );
|
||||
|
||||
for ( PluginExecution e : p.getExecutions() )
|
||||
{
|
||||
// These are bits that look like this:
|
||||
//
|
||||
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
|
||||
//
|
||||
MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, project, session.getLocalRepository() );
|
||||
|
||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor );
|
||||
|
||||
String g = mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId();
|
||||
|
||||
String a = mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId();
|
||||
|
||||
Plugin p = project.getPlugin( g + ":" + a );
|
||||
|
||||
for( PluginExecution e : p.getExecutions() )
|
||||
for ( String goal : e.getGoals() )
|
||||
{
|
||||
for( String goal : e.getGoals() )
|
||||
if ( mojoDescriptor.getGoal().equals( goal ) )
|
||||
{
|
||||
if ( mojoDescriptor.getGoal().equals( goal ) )
|
||||
{
|
||||
Xpp3Dom executionConfiguration = (Xpp3Dom) e.getConfiguration();
|
||||
Xpp3Dom executionConfiguration = (Xpp3Dom) e.getConfiguration();
|
||||
|
||||
Xpp3Dom mojoConfiguration =
|
||||
extractMojoConfiguration( executionConfiguration, mojoDescriptor );
|
||||
Xpp3Dom mojoConfiguration = extractMojoConfiguration( executionConfiguration, mojoDescriptor );
|
||||
|
||||
mojoExecution.setConfiguration( mojoConfiguration );
|
||||
}
|
||||
mojoExecution.setConfiguration( mojoConfiguration );
|
||||
}
|
||||
}
|
||||
|
||||
lifecyclePlan.add( mojoExecution );
|
||||
}
|
||||
|
||||
lifecyclePlan.add( mojoExecution );
|
||||
}
|
||||
|
||||
return lifecyclePlan;
|
||||
|
|
Loading…
Reference in New Issue