mirror of https://github.com/apache/maven.git
MNG-4988 API to calculate execution plan without full mojo execution configuration
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1061589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7bc1814003
commit
e8f8fdbadc
|
@ -25,7 +25,9 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.*;
|
import org.apache.maven.lifecycle.DefaultLifecycles;
|
||||||
|
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||||
|
import org.apache.maven.lifecycle.MavenExecutionPlan;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.PluginExecution;
|
import org.apache.maven.model.PluginExecution;
|
||||||
import org.apache.maven.plugin.MojoExecution;
|
import org.apache.maven.plugin.MojoExecution;
|
||||||
|
@ -45,6 +47,11 @@ public class EmptyLifecycleExecutor
|
||||||
return new MavenExecutionPlan( null, new DefaultLifecycles() );
|
return new MavenExecutionPlan( null, new DefaultLifecycles() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks )
|
||||||
|
{
|
||||||
|
return new MavenExecutionPlan( null, new DefaultLifecycles() );
|
||||||
|
}
|
||||||
|
|
||||||
public void execute( MavenSession session )
|
public void execute( MavenSession session )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -128,14 +129,14 @@ public class DefaultLifecycleExecutor
|
||||||
// Used by m2eclipse
|
// Used by m2eclipse
|
||||||
|
|
||||||
@SuppressWarnings( { "UnusedDeclaration" } )
|
@SuppressWarnings( { "UnusedDeclaration" } )
|
||||||
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks )
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
|
PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
|
||||||
PluginVersionResolutionException
|
PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
|
List<TaskSegment> taskSegments =
|
||||||
List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session );
|
lifecycleTaskSegmentCalculator.calculateTaskSegments( session, Arrays.asList( tasks ) );
|
||||||
|
|
||||||
TaskSegment mergedSegment = new TaskSegment( false );
|
TaskSegment mergedSegment = new TaskSegment( false );
|
||||||
|
|
||||||
|
@ -145,7 +146,16 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
return lifecycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(),
|
return lifecycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(),
|
||||||
mergedSegment.getTasks() );
|
mergedSegment.getTasks(), setup );
|
||||||
|
}
|
||||||
|
|
||||||
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
|
||||||
|
PluginVersionResolutionException
|
||||||
|
{
|
||||||
|
return calculateExecutionPlan( session, true, tasks );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Site 3.x
|
// Site 3.x
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class DefaultSchedules
|
||||||
List<ExecutionPlanItem> result = new ArrayList<ExecutionPlanItem>();
|
List<ExecutionPlanItem> result = new ArrayList<ExecutionPlanItem>();
|
||||||
for ( MojoExecution mojoExecution : executions )
|
for ( MojoExecution mojoExecution : executions )
|
||||||
{
|
{
|
||||||
String lifeCyclePhase = mojoExecution.getMojoDescriptor().getPhase();
|
String lifeCyclePhase = mojoExecution.getLifecyclePhase();
|
||||||
final Scheduling scheduling = getScheduling( "default" );
|
final Scheduling scheduling = getScheduling( "default" );
|
||||||
Schedule schedule = null;
|
Schedule schedule = null;
|
||||||
if ( scheduling != null )
|
if ( scheduling != null )
|
||||||
|
|
|
@ -71,6 +71,12 @@ public interface LifecycleExecutor
|
||||||
PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
|
PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
|
||||||
PluginVersionResolutionException;
|
PluginVersionResolutionException;
|
||||||
|
|
||||||
|
MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException,
|
||||||
|
PluginVersionResolutionException;
|
||||||
|
|
||||||
void execute( MavenSession session );
|
void execute( MavenSession session );
|
||||||
|
|
||||||
// used by the site plugin 3.x
|
// used by the site plugin 3.x
|
||||||
|
|
|
@ -14,6 +14,16 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.maven.lifecycle.internal;
|
package org.apache.maven.lifecycle.internal;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.DefaultLifecycles;
|
import org.apache.maven.lifecycle.DefaultLifecycles;
|
||||||
import org.apache.maven.lifecycle.DefaultSchedules;
|
import org.apache.maven.lifecycle.DefaultSchedules;
|
||||||
|
@ -45,18 +55,6 @@ import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @author Benjamin Bentmann
|
* @author Benjamin Bentmann
|
||||||
|
@ -104,7 +102,7 @@ public class DefaultLifecycleExecutionPlanCalculator
|
||||||
this.defaultSchedules = defaultSchedules;
|
this.defaultSchedules = defaultSchedules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks )
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks, boolean setup )
|
||||||
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
||||||
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
||||||
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
|
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
|
@ -113,42 +111,61 @@ public class DefaultLifecycleExecutionPlanCalculator
|
||||||
|
|
||||||
final List<MojoExecution> executions = calculateMojoExecutions( session, project, tasks );
|
final List<MojoExecution> executions = calculateMojoExecutions( session, project, tasks );
|
||||||
|
|
||||||
setupMojoExections( session, project, executions );
|
if ( setup )
|
||||||
|
{
|
||||||
|
setupMojoExecutions( session, project, executions );
|
||||||
|
}
|
||||||
|
|
||||||
final List<ExecutionPlanItem> planItem = defaultSchedules.createExecutionPlanItem( project, executions );
|
final List<ExecutionPlanItem> planItem = defaultSchedules.createExecutionPlanItem( project, executions );
|
||||||
|
|
||||||
return new MavenExecutionPlan( planItem, defaultLifeCycles );
|
return new MavenExecutionPlan( planItem, defaultLifeCycles );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupMojoExections( MavenSession session, MavenProject project, List<MojoExecution> mojoExecutions )
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
||||||
|
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
||||||
|
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
|
{
|
||||||
|
return calculateExecutionPlan( session, project, tasks, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupMojoExecutions( MavenSession session, MavenProject project, List<MojoExecution> mojoExecutions )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException,
|
MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException,
|
||||||
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
|
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
for ( MojoExecution mojoExecution : mojoExecutions )
|
for ( MojoExecution mojoExecution : mojoExecutions )
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
setupMojoExecution( session, project, mojoExecution );
|
||||||
|
|
||||||
if ( mojoDescriptor == null )
|
|
||||||
{
|
|
||||||
mojoDescriptor =
|
|
||||||
pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
|
|
||||||
project.getRemotePluginRepositories(),
|
|
||||||
session.getRepositorySession() );
|
|
||||||
|
|
||||||
mojoExecution.setMojoDescriptor( mojoDescriptor );
|
|
||||||
}
|
|
||||||
|
|
||||||
populateMojoExecutionConfiguration( project, mojoExecution,
|
|
||||||
MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) );
|
|
||||||
|
|
||||||
finalizeMojoConfiguration( mojoExecution );
|
|
||||||
|
|
||||||
calculateForkedExecutions( mojoExecution, session, project, new HashSet<MojoDescriptor>() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MojoExecution> calculateMojoExecutions( MavenSession session, MavenProject project,
|
public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
|
MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException,
|
||||||
|
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
|
{
|
||||||
|
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||||
|
|
||||||
|
if ( mojoDescriptor == null )
|
||||||
|
{
|
||||||
|
mojoDescriptor =
|
||||||
|
pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
|
||||||
|
project.getRemotePluginRepositories(),
|
||||||
|
session.getRepositorySession() );
|
||||||
|
|
||||||
|
mojoExecution.setMojoDescriptor( mojoDescriptor );
|
||||||
|
}
|
||||||
|
|
||||||
|
populateMojoExecutionConfiguration( project, mojoExecution,
|
||||||
|
MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) );
|
||||||
|
|
||||||
|
finalizeMojoConfiguration( mojoExecution );
|
||||||
|
|
||||||
|
calculateForkedExecutions( mojoExecution, session, project, new HashSet<MojoDescriptor>() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MojoExecution> calculateMojoExecutions( MavenSession session, MavenProject project,
|
||||||
List<Object> tasks )
|
List<Object> tasks )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
|
|
@ -48,11 +48,20 @@ public interface LifecycleExecutionPlanCalculator
|
||||||
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
||||||
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException;
|
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException;
|
||||||
|
|
||||||
|
MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks,
|
||||||
|
boolean setup )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
||||||
|
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
||||||
|
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException;
|
||||||
|
|
||||||
void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session )
|
void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session )
|
||||||
throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
|
throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
|
||||||
PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
|
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
|
||||||
|
|
||||||
|
void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
|
MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException,
|
||||||
|
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,11 @@ public interface LifecycleTaskSegmentCalculator
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException;
|
PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException;
|
||||||
|
|
||||||
|
public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
PluginVersionResolutionException;
|
||||||
|
|
||||||
boolean requiresProject( MavenSession session );
|
boolean requiresProject( MavenSession session );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,8 @@ public class LifecycleExecutionPlanCalculatorStub
|
||||||
// Maybe do something ?
|
// Maybe do something ?
|
||||||
}
|
}
|
||||||
|
|
||||||
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks )
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks,
|
||||||
|
boolean setup )
|
||||||
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
||||||
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
||||||
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
|
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
|
@ -131,6 +132,21 @@ public class LifecycleExecutionPlanCalculatorStub
|
||||||
return createExecutionPlan( project, me );
|
return createExecutionPlan( project, me );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
||||||
|
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
||||||
|
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
|
{
|
||||||
|
return calculateExecutionPlan( session, project, tasks, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
|
MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException,
|
||||||
|
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public static MavenExecutionPlan getProjectAExceutionPlan()
|
public static MavenExecutionPlan getProjectAExceutionPlan()
|
||||||
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
|
||||||
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
|
||||||
|
|
|
@ -46,6 +46,11 @@ public class EmptyLifecycleExecutor
|
||||||
return new MavenExecutionPlan( null, null );
|
return new MavenExecutionPlan( null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks )
|
||||||
|
{
|
||||||
|
return new MavenExecutionPlan( null, null );
|
||||||
|
}
|
||||||
|
|
||||||
public void execute( MavenSession session )
|
public void execute( MavenSession session )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue