mirror of https://github.com/apache/maven.git
o Refactoring: Moved one incorrectly placed method from BuildListCalculator to TaskSegmentCalculator
This method was creating a lot of strange internal dependencies since it was mis-placed git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@935741 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b329fdb4e5
commit
2339e16750
|
@ -126,7 +126,7 @@ public class DefaultLifecycleExecutor
|
||||||
boolean isThreaded = executionRequest.isThreadConfigurationPresent();
|
boolean isThreaded = executionRequest.isThreadConfigurationPresent();
|
||||||
session.setParallel( isThreaded );
|
session.setParallel( isThreaded );
|
||||||
|
|
||||||
List<TaskSegment> taskSegments = buildListCalculator.calculateTaskSegments( session );
|
List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session );
|
||||||
|
|
||||||
ProjectBuildList projectBuilds = buildListCalculator.calculateProjectBuilds( session, taskSegments );
|
ProjectBuildList projectBuilds = buildListCalculator.calculateProjectBuilds( session, taskSegments );
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ public class DefaultLifecycleExecutor
|
||||||
PluginVersionResolutionException
|
PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
|
|
||||||
List<TaskSegment> taskSegments = buildListCalculator.calculateTaskSegments( session );
|
List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session );
|
||||||
|
|
||||||
TaskSegment mergedSegment = new TaskSegment( false );
|
TaskSegment mergedSegment = new TaskSegment( false );
|
||||||
|
|
||||||
|
|
|
@ -15,18 +15,10 @@
|
||||||
package org.apache.maven.lifecycle.internal;
|
package org.apache.maven.lifecycle.internal;
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.LifecycleNotFoundException;
|
|
||||||
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
|
||||||
import org.apache.maven.plugin.*;
|
|
||||||
import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
|
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
|
||||||
import org.apache.maven.project.MavenProject;
|
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.util.StringUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -37,40 +29,6 @@ import java.util.List;
|
||||||
@Component( role = BuildListCalculator.class )
|
@Component( role = BuildListCalculator.class )
|
||||||
public class BuildListCalculator
|
public class BuildListCalculator
|
||||||
{
|
{
|
||||||
@Requirement
|
|
||||||
private LifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator;
|
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"})
|
|
||||||
public BuildListCalculator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BuildListCalculator( LifecycleTaskSegmentCalculator lifeCycleTaskSegmentCalculator )
|
|
||||||
{
|
|
||||||
this.lifeCycleTaskSegmentCalculator = lifeCycleTaskSegmentCalculator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TaskSegment> calculateTaskSegments( MavenSession session )
|
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
|
||||||
PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException
|
|
||||||
{
|
|
||||||
|
|
||||||
MavenProject rootProject = session.getTopLevelProject();
|
|
||||||
|
|
||||||
List<String> tasks = session.getGoals();
|
|
||||||
|
|
||||||
if ( tasks == null || tasks.isEmpty() )
|
|
||||||
{
|
|
||||||
if ( !StringUtils.isEmpty( rootProject.getDefaultGoal() ) )
|
|
||||||
{
|
|
||||||
tasks = Arrays.asList( StringUtils.split( rootProject.getDefaultGoal() ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lifeCycleTaskSegmentCalculator.calculateTaskSegments( session, tasks );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectBuildList calculateProjectBuilds( MavenSession session, List<TaskSegment> taskSegments )
|
public ProjectBuildList calculateProjectBuilds( MavenSession session, List<TaskSegment> taskSegments )
|
||||||
{
|
{
|
||||||
List<ProjectSegment> projectBuilds = new ArrayList<ProjectSegment>();
|
List<ProjectSegment> projectBuilds = new ArrayList<ProjectSegment>();
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
package org.apache.maven.lifecycle.internal;
|
package org.apache.maven.lifecycle.internal;
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
|
import org.apache.maven.lifecycle.LifecycleNotFoundException;
|
||||||
|
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
||||||
import org.apache.maven.plugin.*;
|
import org.apache.maven.plugin.*;
|
||||||
import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
|
import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
|
@ -34,10 +36,10 @@ import java.util.List;
|
||||||
|
|
||||||
public interface LifecycleTaskSegmentCalculator
|
public interface LifecycleTaskSegmentCalculator
|
||||||
{
|
{
|
||||||
List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks )
|
public List<TaskSegment> calculateTaskSegments( MavenSession session )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
PluginVersionResolutionException;
|
PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException;
|
||||||
|
|
||||||
public boolean requiresProject( MavenSession session );
|
public boolean requiresProject( MavenSession session );
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,23 @@
|
||||||
package org.apache.maven.lifecycle.internal;
|
package org.apache.maven.lifecycle.internal;
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.plugin.*;
|
import org.apache.maven.lifecycle.LifecycleNotFoundException;
|
||||||
|
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
||||||
|
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
||||||
|
import org.apache.maven.plugin.MojoNotFoundException;
|
||||||
|
import org.apache.maven.plugin.PluginDescriptorParsingException;
|
||||||
|
import org.apache.maven.plugin.PluginNotFoundException;
|
||||||
|
import org.apache.maven.plugin.PluginResolutionException;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
|
import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
|
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 org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +59,27 @@ public class LifecycleTaskSegmentCalculatorImpl
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TaskSegment> calculateTaskSegments( MavenSession session )
|
||||||
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException
|
||||||
|
{
|
||||||
|
|
||||||
|
MavenProject rootProject = session.getTopLevelProject();
|
||||||
|
|
||||||
|
List<String> tasks = session.getGoals();
|
||||||
|
|
||||||
|
if ( tasks == null || tasks.isEmpty() )
|
||||||
|
{
|
||||||
|
if ( !StringUtils.isEmpty( rootProject.getDefaultGoal() ) )
|
||||||
|
{
|
||||||
|
tasks = Arrays.asList( StringUtils.split( rootProject.getDefaultGoal() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return calculateTaskSegments( session, tasks );
|
||||||
|
}
|
||||||
|
|
||||||
public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks )
|
public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
|
|
@ -105,12 +105,13 @@ public class LifecycleWeaveBuilder
|
||||||
for ( TaskSegment taskSegment : taskSegments )
|
for ( TaskSegment taskSegment : taskSegments )
|
||||||
{
|
{
|
||||||
ProjectBuildList segmentChunks = projectBuilds.getByTaskSegment( taskSegment );
|
ProjectBuildList segmentChunks = projectBuilds.getByTaskSegment( taskSegment );
|
||||||
ThreadOutputMuxer muxer = null; // new ThreadOutputMuxer( segmentChunks, System.out );
|
|
||||||
Set<String> projectArtifacts = new HashSet<String>();
|
Set<String> projectArtifacts = new HashSet<String>();
|
||||||
Set<Artifact> projectArtifactsA = new HashSet<Artifact>();
|
Set<Artifact> projectArtifactsA = new HashSet<Artifact>();
|
||||||
for (ProjectSegment segmentChunk : segmentChunks) {
|
for ( ProjectSegment segmentChunk : segmentChunks )
|
||||||
|
{
|
||||||
Artifact artifact = segmentChunk.getProject().getArtifact();
|
Artifact artifact = segmentChunk.getProject().getArtifact();
|
||||||
if (artifact != null) {
|
if ( artifact != null )
|
||||||
|
{
|
||||||
projectArtifacts.add( ArtifactUtils.key( artifact ) );
|
projectArtifacts.add( ArtifactUtils.key( artifact ) );
|
||||||
projectArtifactsA.add( artifact );
|
projectArtifactsA.add( artifact );
|
||||||
}
|
}
|
||||||
|
@ -122,9 +123,11 @@ public class LifecycleWeaveBuilder
|
||||||
MavenExecutionPlan executionPlan =
|
MavenExecutionPlan executionPlan =
|
||||||
builderCommon.resolveBuildPlan( projectBuild.getSession(), projectBuild.getProject(),
|
builderCommon.resolveBuildPlan( projectBuild.getSession(), projectBuild.getProject(),
|
||||||
projectBuild.getTaskSegment(), projectArtifactsA );
|
projectBuild.getTaskSegment(), projectArtifactsA );
|
||||||
for (Artifact dependency : projectBuild.getProject().getDependencyArtifacts()) {
|
for ( Artifact dependency : projectBuild.getProject().getDependencyArtifacts() )
|
||||||
|
{
|
||||||
String s = ArtifactUtils.key( dependency );
|
String s = ArtifactUtils.key( dependency );
|
||||||
if ( projectArtifacts.contains(s)){
|
if ( projectArtifacts.contains( s ) )
|
||||||
|
{
|
||||||
dependency.setFile( null );
|
dependency.setFile( null );
|
||||||
dependency.setResolved( false );
|
dependency.setResolved( false );
|
||||||
dependency.setRepository( null );
|
dependency.setRepository( null );
|
||||||
|
@ -137,9 +140,8 @@ public class LifecycleWeaveBuilder
|
||||||
|
|
||||||
final Callable<ProjectSegment> projectBuilder =
|
final Callable<ProjectSegment> projectBuilder =
|
||||||
createCallableForBuildingOneFullModule( buildContext, session, reactorBuildStatus,
|
createCallableForBuildingOneFullModule( buildContext, session, reactorBuildStatus,
|
||||||
executionPlan, projectBuild, muxer,
|
executionPlan, projectBuild, dependencyContext,
|
||||||
dependencyContext, concurrentBuildLogger,
|
concurrentBuildLogger );
|
||||||
projectBuilds );
|
|
||||||
|
|
||||||
futures.add( service.submit( projectBuilder ) );
|
futures.add( service.submit( projectBuilder ) );
|
||||||
}
|
}
|
||||||
|
@ -169,10 +171,8 @@ public class LifecycleWeaveBuilder
|
||||||
final ReactorBuildStatus reactorBuildStatus,
|
final ReactorBuildStatus reactorBuildStatus,
|
||||||
final MavenExecutionPlan executionPlan,
|
final MavenExecutionPlan executionPlan,
|
||||||
final ProjectSegment projectBuild,
|
final ProjectSegment projectBuild,
|
||||||
final ThreadOutputMuxer muxer,
|
|
||||||
final DependencyContext dependencyContext,
|
final DependencyContext dependencyContext,
|
||||||
final ConcurrentBuildLogger concurrentBuildLogger,
|
final ConcurrentBuildLogger concurrentBuildLogger )
|
||||||
final ProjectBuildList projectBuilds )
|
|
||||||
{
|
{
|
||||||
return new Callable<ProjectSegment>()
|
return new Callable<ProjectSegment>()
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,8 @@ public class LifecycleWeaveBuilder
|
||||||
concurrentBuildLogger.createBuildLogItem( projectBuild.getProject(), current );
|
concurrentBuildLogger.createBuildLogItem( projectBuild.getProject(), current );
|
||||||
final Schedule schedule = current.getSchedule();
|
final Schedule schedule = current.getSchedule();
|
||||||
|
|
||||||
buildExecutionPlanItem(current, phaseRecorder, schedule, reactorContext, projectBuild, dependencyContext);
|
buildExecutionPlanItem( current, phaseRecorder, schedule, reactorContext, projectBuild,
|
||||||
|
dependencyContext );
|
||||||
|
|
||||||
current.setComplete();
|
current.setComplete();
|
||||||
builtLogItem.setComplete();
|
builtLogItem.setComplete();
|
||||||
|
@ -215,7 +216,8 @@ public class LifecycleWeaveBuilder
|
||||||
final Schedule scheduleOfNext = nextPlanItem.getSchedule();
|
final Schedule scheduleOfNext = nextPlanItem.getSchedule();
|
||||||
if ( scheduleOfNext == null || !scheduleOfNext.isParallel() )
|
if ( scheduleOfNext == null || !scheduleOfNext.isParallel() )
|
||||||
{
|
{
|
||||||
waitForAppropriateUpstreamExecutionsToFinish(builtLogItem, nextPlanItem, projectBuild);
|
waitForAppropriateUpstreamExecutionsToFinish( builtLogItem, nextPlanItem,
|
||||||
|
projectBuild );
|
||||||
}
|
}
|
||||||
reResolveReactorDependencies( nextPlanItem, projectBuild );
|
reResolveReactorDependencies( nextPlanItem, projectBuild );
|
||||||
}
|
}
|
||||||
|
@ -247,7 +249,8 @@ public class LifecycleWeaveBuilder
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reResolveReactorDependencies(ExecutionPlanItem nextPlanItem, ProjectSegment projectBuild) {
|
private void reResolveReactorDependencies( ExecutionPlanItem nextPlanItem, ProjectSegment projectBuild )
|
||||||
|
{
|
||||||
if ( requiresReResolutionOfUpstreamReactorArtifacts( nextPlanItem ) )
|
if ( requiresReResolutionOfUpstreamReactorArtifacts( nextPlanItem ) )
|
||||||
{
|
{
|
||||||
reresolveUpstreamProjectArtifacts( projectBuild );
|
reresolveUpstreamProjectArtifacts( projectBuild );
|
||||||
|
@ -258,7 +261,11 @@ public class LifecycleWeaveBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForAppropriateUpstreamExecutionsToFinish(BuildLogItem builtLogItem, ExecutionPlanItem nextPlanItem, ProjectSegment projectBuild) throws InterruptedException {
|
private void waitForAppropriateUpstreamExecutionsToFinish( BuildLogItem builtLogItem,
|
||||||
|
ExecutionPlanItem nextPlanItem,
|
||||||
|
ProjectSegment projectBuild )
|
||||||
|
throws InterruptedException
|
||||||
|
{
|
||||||
for ( MavenProject upstreamProject : projectBuild.getImmediateUpstreamProjects() )
|
for ( MavenProject upstreamProject : projectBuild.getImmediateUpstreamProjects() )
|
||||||
{
|
{
|
||||||
final MavenExecutionPlan upstreamPlan = executionPlans.get( upstreamProject );
|
final MavenExecutionPlan upstreamPlan = executionPlans.get( upstreamProject );
|
||||||
|
@ -286,11 +293,14 @@ public class LifecycleWeaveBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reresolveUpstreamProjectArtifacts(ProjectSegment projectBuild) {
|
private void reresolveUpstreamProjectArtifacts( ProjectSegment projectBuild )
|
||||||
for ( MavenProject upstreamProject : projectBuild.getTransitiveUpstreamProjects() ){
|
{
|
||||||
|
for ( MavenProject upstreamProject : projectBuild.getTransitiveUpstreamProjects() )
|
||||||
|
{
|
||||||
Artifact upStreamArtifact = upstreamProject.getArtifact();
|
Artifact upStreamArtifact = upstreamProject.getArtifact();
|
||||||
Artifact dependencyArtifact = findDependency( projectBuild.getProject(), upStreamArtifact );
|
Artifact dependencyArtifact = findDependency( projectBuild.getProject(), upStreamArtifact );
|
||||||
if (dependencyArtifact != null){
|
if ( dependencyArtifact != null )
|
||||||
|
{
|
||||||
dependencyArtifact.setFile( upStreamArtifact.getFile() );
|
dependencyArtifact.setFile( upStreamArtifact.getFile() );
|
||||||
dependencyArtifact.setResolved( true );
|
dependencyArtifact.setResolved( true );
|
||||||
dependencyArtifact.setRepository( upStreamArtifact.getRepository() );
|
dependencyArtifact.setRepository( upStreamArtifact.getRepository() );
|
||||||
|
@ -299,11 +309,14 @@ public class LifecycleWeaveBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reresolveUpstreamTestScopedArtifacts(ProjectSegment projectBuild) {
|
private void reresolveUpstreamTestScopedArtifacts( ProjectSegment projectBuild )
|
||||||
for ( MavenProject upstreamProject : projectBuild.getTransitiveUpstreamProjects() ){
|
{
|
||||||
|
for ( MavenProject upstreamProject : projectBuild.getTransitiveUpstreamProjects() )
|
||||||
|
{
|
||||||
Artifact upStreamArtifact = findTestScopedArtifact( upstreamProject );
|
Artifact upStreamArtifact = findTestScopedArtifact( upstreamProject );
|
||||||
Artifact dependencyArtifact = findDependency( projectBuild.getProject(), upStreamArtifact );
|
Artifact dependencyArtifact = findDependency( projectBuild.getProject(), upStreamArtifact );
|
||||||
if (dependencyArtifact != null){
|
if ( dependencyArtifact != null )
|
||||||
|
{
|
||||||
dependencyArtifact.setFile( upStreamArtifact.getFile() );
|
dependencyArtifact.setFile( upStreamArtifact.getFile() );
|
||||||
dependencyArtifact.setResolved( upStreamArtifact.isResolved() );
|
dependencyArtifact.setResolved( upStreamArtifact.isResolved() );
|
||||||
dependencyArtifact.setRepository( upStreamArtifact.getRepository() );
|
dependencyArtifact.setRepository( upStreamArtifact.getRepository() );
|
||||||
|
@ -312,27 +325,32 @@ public class LifecycleWeaveBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Artifact findTestScopedArtifact(MavenProject upstreamProject) {
|
private Artifact findTestScopedArtifact( MavenProject upstreamProject )
|
||||||
if ( upstreamProject == null){
|
{
|
||||||
|
if ( upstreamProject == null )
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Artifact> artifactList = upstreamProject.getAttachedArtifacts();
|
List<Artifact> artifactList = upstreamProject.getAttachedArtifacts();
|
||||||
for (Artifact artifact : artifactList) {
|
for ( Artifact artifact : artifactList )
|
||||||
if (Artifact.SCOPE_TEST.equals( artifact.getScope())){
|
{
|
||||||
|
if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
|
||||||
|
{
|
||||||
return artifact;
|
return artifact;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Artifact findDependency(MavenProject project, Artifact upStreamArtifact) {
|
private static Artifact findDependency( MavenProject project, Artifact upStreamArtifact )
|
||||||
if (upStreamArtifact == null){
|
{
|
||||||
|
if ( upStreamArtifact == null )
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String key = ArtifactUtils.key( upStreamArtifact.getGroupId(),
|
String key = ArtifactUtils.key( upStreamArtifact.getGroupId(), upStreamArtifact.getArtifactId(),
|
||||||
upStreamArtifact.getArtifactId(),
|
|
||||||
upStreamArtifact.getVersion() );
|
upStreamArtifact.getVersion() );
|
||||||
final Set<Artifact> deps = project.getDependencyArtifacts();
|
final Set<Artifact> deps = project.getDependencyArtifacts();
|
||||||
for ( Artifact dep : deps )
|
for ( Artifact dep : deps )
|
||||||
|
@ -356,22 +374,25 @@ public class LifecycleWeaveBuilder
|
||||||
private boolean requiresReResolutionOfUpstreamTestScopedReactorArtifacts( ExecutionPlanItem nextExecutionPlanItem )
|
private boolean requiresReResolutionOfUpstreamTestScopedReactorArtifacts( ExecutionPlanItem nextExecutionPlanItem )
|
||||||
{
|
{
|
||||||
final String phase = nextExecutionPlanItem.getLifecyclePhase();
|
final String phase = nextExecutionPlanItem.getLifecyclePhase();
|
||||||
return "package".equals(phase) || "install".equals( phase ) || "compile".equals( phase ) || "test-compile".equals( phase );
|
return "package".equals( phase ) || "install".equals( phase ) || "compile".equals( phase ) ||
|
||||||
|
"test-compile".equals( phase );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildExecutionPlanItem(ExecutionPlanItem current, PhaseRecorder phaseRecorder, Schedule schedule, ReactorContext reactorContext, ProjectSegment projectBuild, DependencyContext dependencyContext) throws LifecycleExecutionException {
|
private void buildExecutionPlanItem( ExecutionPlanItem current, PhaseRecorder phaseRecorder, Schedule schedule,
|
||||||
|
ReactorContext reactorContext, ProjectSegment projectBuild,
|
||||||
|
DependencyContext dependencyContext )
|
||||||
|
throws LifecycleExecutionException
|
||||||
|
{
|
||||||
if ( schedule != null && schedule.isMojoSynchronized() )
|
if ( schedule != null && schedule.isMojoSynchronized() )
|
||||||
{
|
{
|
||||||
synchronized ( current.getPlugin() )
|
synchronized ( current.getPlugin() )
|
||||||
{
|
{
|
||||||
buildExecutionPlanItem( reactorContext, current, projectBuild, dependencyContext,
|
buildExecutionPlanItem( reactorContext, current, projectBuild, dependencyContext, phaseRecorder );
|
||||||
phaseRecorder );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buildExecutionPlanItem( reactorContext, current, projectBuild, dependencyContext,
|
buildExecutionPlanItem( reactorContext, current, projectBuild, dependencyContext, phaseRecorder );
|
||||||
phaseRecorder );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,9 +305,6 @@ public class LifecycleExecutorTest
|
||||||
System.out.println( dom );
|
System.out.println( dom );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo: This method is kind of an oddity. It is only called from the LifecycleExecutorTest, hence it should
|
|
||||||
// really not exist, or at least be moved into the test class.
|
|
||||||
|
|
||||||
MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks )
|
MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
|
|
@ -29,9 +29,10 @@ public class BuildListCalculatorTest
|
||||||
public void testCalculateProjectBuilds()
|
public void testCalculateProjectBuilds()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
BuildListCalculator buildListCalculator = createBuildListCalculator();
|
LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator();
|
||||||
|
BuildListCalculator buildListCalculator = new BuildListCalculator();
|
||||||
final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
|
final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
|
||||||
List<TaskSegment> taskSegments = buildListCalculator.calculateTaskSegments( session );
|
List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session );
|
||||||
final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments );
|
final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments );
|
||||||
final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) );
|
final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) );
|
||||||
assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() );
|
assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() );
|
||||||
|
@ -40,10 +41,9 @@ public class BuildListCalculatorTest
|
||||||
assertNotNull( build );
|
assertNotNull( build );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BuildListCalculator createBuildListCalculator()
|
private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator()
|
||||||
{
|
{
|
||||||
LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = new LifecycleTaskSegmentCalculatorStub();
|
return new LifecycleTaskSegmentCalculatorStub();
|
||||||
return new BuildListCalculator( lifecycleTaskSegmentCalculator );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package org.apache.maven.lifecycle.internal;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.apache.maven.execution.MavenSession;
|
||||||
|
import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub;
|
||||||
|
import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:kristian@zenior.no">Kristian Rosenvold</a>
|
||||||
|
*/
|
||||||
|
public class LifecycleTaskSegmentCalculatorImplTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
public void testCalculateProjectBuilds()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator();
|
||||||
|
BuildListCalculator buildListCalculator = new BuildListCalculator();
|
||||||
|
final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
|
||||||
|
List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session );
|
||||||
|
|
||||||
|
final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments );
|
||||||
|
final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) );
|
||||||
|
assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() );
|
||||||
|
assertEquals( "Stub data contains 6 items", 6, segments.size() );
|
||||||
|
final ProjectSegment build = segments.get( 0 );
|
||||||
|
assertNotNull( build );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator()
|
||||||
|
{
|
||||||
|
return new LifecycleTaskSegmentCalculatorStub();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -20,13 +20,7 @@ import org.apache.maven.execution.MavenExecutionResult;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.LifecycleNotFoundException;
|
import org.apache.maven.lifecycle.LifecycleNotFoundException;
|
||||||
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
||||||
import org.apache.maven.lifecycle.internal.stub.CompletionServiceStub;
|
import org.apache.maven.lifecycle.internal.stub.*;
|
||||||
import org.apache.maven.lifecycle.internal.stub.ExecutionEventCatapultStub;
|
|
||||||
import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub;
|
|
||||||
import org.apache.maven.lifecycle.internal.stub.LoggerStub;
|
|
||||||
import org.apache.maven.lifecycle.internal.stub.MojoExecutorStub;
|
|
||||||
import org.apache.maven.lifecycle.internal.stub.ProjectDependenciesResolverStub;
|
|
||||||
import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
|
|
||||||
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
||||||
import org.apache.maven.plugin.MojoNotFoundException;
|
import org.apache.maven.plugin.MojoNotFoundException;
|
||||||
import org.apache.maven.plugin.PluginDescriptorParsingException;
|
import org.apache.maven.plugin.PluginDescriptorParsingException;
|
||||||
|
@ -85,9 +79,9 @@ public class LifecycleWeaveBuilderTest
|
||||||
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildListCalculator buildListCalculator = BuildListCalculatorTest.createBuildListCalculator();
|
BuildListCalculator buildListCalculator = new BuildListCalculator();
|
||||||
final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
|
final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
|
||||||
List<TaskSegment> taskSegments = buildListCalculator.calculateTaskSegments( session );
|
List<TaskSegment> taskSegments = getTaskSegmentCalculator().calculateTaskSegments( session );
|
||||||
ProjectBuildList projectBuildList = buildListCalculator.calculateProjectBuilds( session, taskSegments );
|
ProjectBuildList projectBuildList = buildListCalculator.calculateProjectBuilds( session, taskSegments );
|
||||||
|
|
||||||
final MojoExecutorStub mojoExecutorStub = new MojoExecutorStub();
|
final MojoExecutorStub mojoExecutorStub = new MojoExecutorStub();
|
||||||
|
@ -109,6 +103,11 @@ public class LifecycleWeaveBuilderTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator()
|
||||||
|
{
|
||||||
|
return new LifecycleTaskSegmentCalculatorStub();
|
||||||
|
}
|
||||||
|
|
||||||
private ReactorContext createBuildContext( MavenSession session )
|
private ReactorContext createBuildContext( MavenSession session )
|
||||||
{
|
{
|
||||||
MavenExecutionResult mavenExecutionResult = new DefaultMavenExecutionResult();
|
MavenExecutionResult mavenExecutionResult = new DefaultMavenExecutionResult();
|
||||||
|
@ -120,8 +119,6 @@ public class LifecycleWeaveBuilderTest
|
||||||
{
|
{
|
||||||
final BuilderCommon builderCommon = getBuilderCommon();
|
final BuilderCommon builderCommon = getBuilderCommon();
|
||||||
final LoggerStub loggerStub = new LoggerStub();
|
final LoggerStub loggerStub = new LoggerStub();
|
||||||
final LifecycleDependencyResolver lifecycleDependencyResolver =
|
|
||||||
new LifecycleDependencyResolver( new ProjectDependenciesResolverStub(), loggerStub );
|
|
||||||
return new LifecycleWeaveBuilder( mojoExecutor, builderCommon, loggerStub, new ExecutionEventCatapultStub() );
|
return new LifecycleWeaveBuilder( mojoExecutor, builderCommon, loggerStub, new ExecutionEventCatapultStub() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.maven.lifecycle.internal.stub;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.internal.GoalTask;
|
import org.apache.maven.lifecycle.internal.GoalTask;
|
||||||
import org.apache.maven.lifecycle.internal.LifecycleTask;
|
import org.apache.maven.lifecycle.internal.LifecycleTask;
|
||||||
import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator;
|
import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculatorImpl;
|
||||||
import org.apache.maven.lifecycle.internal.TaskSegment;
|
import org.apache.maven.lifecycle.internal.TaskSegment;
|
||||||
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
||||||
import org.apache.maven.plugin.MojoNotFoundException;
|
import org.apache.maven.plugin.MojoNotFoundException;
|
||||||
|
@ -36,7 +36,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LifecycleTaskSegmentCalculatorStub
|
public class LifecycleTaskSegmentCalculatorStub
|
||||||
implements LifecycleTaskSegmentCalculator
|
extends LifecycleTaskSegmentCalculatorImpl
|
||||||
{
|
{
|
||||||
public static final String clean = "clean";
|
public static final String clean = "clean";
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ public class LifecycleTaskSegmentCalculatorStub
|
||||||
|
|
||||||
public static final String install = "install";
|
public static final String install = "install";
|
||||||
|
|
||||||
|
|
||||||
public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks )
|
public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks )
|
||||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
|
||||||
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||||
|
|
Loading…
Reference in New Issue