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 MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks, boolean setup ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { lifecyclePluginResolver.resolveMissingPluginVersions( project, session ); final List<MojoExecution> executions = calculateMojoExecutions( session, project, tasks ); if ( setup ) { setupMojoExecutions( session, project, executions ); } final List<ExecutionPlanItem> planItem = defaultSchedules.createExecutionPlanItem( project, executions ); return new MavenExecutionPlan( planItem, defaultLifeCycles ); }
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>() ); }
@SuppressWarnings( { "UnusedDeclaration" } ) public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session, Arrays.asList( tasks ) ); TaskSegment mergedSegment = new TaskSegment( false ); for ( TaskSegment taskSegment : taskSegments ) { mergedSegment.getTasks().addAll( taskSegment.getTasks() ); } return lifecycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(), mergedSegment.getTasks(), setup ); }
public PluginVersionResult resolve( PluginVersionRequest request ) throws PluginVersionResolutionException { logger.debug( "Resolving plugin version for " + request.getGroupId() + ":" + request.getArtifactId() ); PluginVersionResult result = resolveFromProject( request ); if ( result == null ) { result = resolveFromRepository( request ); if ( logger.isDebugEnabled() ) { logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() + " to " + result.getVersion() + " from repository " + result.getRepository() ); } } else if ( logger.isDebugEnabled() ) { logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId() + " to " + result.getVersion() + " from POM " + request.getPom() ); } return result; }
public PluginDescriptor loadPluginFully( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { PluginDescriptor pluginDescriptor = loadPluginDescriptor( plugin, project, session ); try { pluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); } catch ( PluginResolutionException e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } return pluginDescriptor; }
public void testConcurrencyGraphDifferentCompletionOrder() throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraphStub(); final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); ConcurrencyDependencyGraph graph = new ConcurrencyDependencyGraph( getProjectBuildList( session ), dependencyGraph ); graph.markAsFinished( A ); final List<MavenProject> cDescendants = graph.markAsFinished( C ); assertEquals( 1, cDescendants.size() ); assertEquals( Z, cDescendants.get( 0 ) ); final List<MavenProject> bDescendants = graph.markAsFinished( B ); assertEquals( 2, bDescendants.size() ); assertEquals( X, bDescendants.get( 0 ) ); assertEquals( Y, bDescendants.get( 1 ) ); }
public static List<ProjectSegment> getProjectBuilds( MavenSession session ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, PluginNotFoundException, MojoNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { List<ProjectSegment> projectBuilds = new ArrayList<ProjectSegment>(); TaskSegment segment = createTaskSegment(); projectBuilds.add( createProjectBuild( A, session, segment ) ); projectBuilds.add( createProjectBuild( B, session, segment ) ); projectBuilds.add( createProjectBuild( C, session, segment ) ); projectBuilds.add( createProjectBuild( X, session, segment ) ); projectBuilds.add( createProjectBuild( Y, session, segment ) ); projectBuilds.add( createProjectBuild( Z, session, segment ) ); return projectBuilds; }
public PluginVersionResult resolve( PluginVersionRequest request ) throws PluginVersionResolutionException { return new PluginVersionResult() { public String getVersion() { return "0.42"; } public ArtifactRepository getRepository() { return null; } }; }
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, MavenProject project, List<Object> tasks, boolean setup ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { if ( project.equals( ProjectDependencyGraphStub.A ) ) { return getProjectAExceutionPlan(); } if ( project.equals( ProjectDependencyGraphStub.B ) ) { return getProjectBExecutionPlan(); } // The remaining are basically "for future expansion" List<MojoExecution> me = new ArrayList<MojoExecution>(); me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); return createExecutionPlan( project, me ); }
public static MavenExecutionPlan getProjectAExceutionPlan() throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { List<MojoExecution> me = new ArrayList<MojoExecution>(); me.add( createMojoExecution( "initialize", "default-initialize", INITIALIZE ) ); me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); me.add( createMojoExecution( "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) ); me.add( createMojoExecution( "testCompile", "default-testCompile", TEST_COMPILE ) ); me.add( createMojoExecution( "test", "default-test", TEST ) ); me.add( createMojoExecution( "war", "default-war", PACKAGE ) ); me.add( createMojoExecution( "install", "default-install", INSTALL ) ); return createExecutionPlan( ProjectDependencyGraphStub.A.getExecutionProject(), 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 ); }
private void setupMojoExecutions( MavenSession session, MavenProject project, List<MojoExecution> mojoExecutions ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { for ( MojoExecution mojoExecution : mojoExecutions ) { setupMojoExecution( session, project, mojoExecution ); } }
public List<MojoExecution> calculateMojoExecutions( MavenSession session, MavenProject project, List<Object> tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException { final List<MojoExecution> mojoExecutions = new ArrayList<MojoExecution>(); for ( Object task : tasks ) { if ( task instanceof GoalTask ) { String pluginGoal = ( (GoalTask) task ).pluginGoal; MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor( pluginGoal, session, project ); MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, "default-cli", MojoExecution.Source.CLI ); mojoExecutions.add( mojoExecution ); } else if ( task instanceof LifecycleTask ) { String lifecyclePhase = ( (LifecycleTask) task ).getLifecyclePhase(); Map<String, List<MojoExecution>> phaseToMojoMapping = calculateLifecycleMappings( session, project, lifecyclePhase ); for ( List<MojoExecution> mojoExecutionsFromLifecycle : phaseToMojoMapping.values() ) { mojoExecutions.addAll( mojoExecutionsFromLifecycle ); } } else { throw new IllegalStateException( "unexpected task " + task ); } } return mojoExecutions; }
public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { calculateForkedExecutions( mojoExecution, session, session.getCurrentProject(), new HashSet<MojoDescriptor>() ); }
private List<MojoExecution> calculateForkedGoal( MojoExecution mojoExecution, MavenSession session, MavenProject project, Collection<MojoDescriptor> alreadyForkedExecutions ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); String forkedGoal = mojoDescriptor.getExecuteGoal(); MojoDescriptor forkedMojoDescriptor = pluginDescriptor.getMojo( forkedGoal ); if ( forkedMojoDescriptor == null ) { throw new MojoNotFoundException( forkedGoal, pluginDescriptor ); } if ( alreadyForkedExecutions.contains( forkedMojoDescriptor ) ) { return Collections.emptyList(); } MojoExecution forkedExecution = new MojoExecution( forkedMojoDescriptor, forkedGoal ); populateMojoExecutionConfiguration( project, forkedExecution, true ); finalizeMojoConfiguration( forkedExecution ); calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions ); return Collections.singletonList( forkedExecution ); }
public Plugin findPluginForPrefix( String prefix, MavenSession session ) throws NoPluginFoundForPrefixException { // [prefix]:[goal] if ( session.getCurrentProject() != null ) { try { lifecyclePluginResolver.resolveMissingPluginVersions( session.getCurrentProject(), session ); } catch ( PluginVersionResolutionException e ) { // not critical here logger.debug( e.getMessage(), e ); } } PluginPrefixRequest prefixRequest = new DefaultPluginPrefixRequest( prefix, session ); PluginPrefixResult prefixResult = pluginPrefixResolver.resolve( prefixRequest ); Plugin plugin = new Plugin(); plugin.setGroupId( prefixResult.getGroupId() ); plugin.setArtifactId( prefixResult.getArtifactId() ); return plugin; }
private void resolvePluginVersion( Plugin plugin, MavenSession session, MavenProject project ) throws PluginVersionResolutionException { PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), project.getRemotePluginRepositories() ); plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() ); }
@SuppressWarnings( { "UnusedDeclaration" } ) MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project, String invokedVia, boolean canUsePrefix, boolean isOptionalMojo ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException { return mojoDescriptorCreator.getMojoDescriptor( task, session, project ); }
public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { return calculateExecutionPlan( session, true, tasks ); }
public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { lifecycleExecutionPlanCalculator.calculateForkedExecutions( mojoExecution, session ); }
public PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { return verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() ); }
private ProjectBuildList runWithCompletionService( ExecutorService service ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, ExecutionException, InterruptedException { final ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { BuildListCalculator buildListCalculator = new BuildListCalculator(); final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); List<TaskSegment> taskSegments = getTaskSegmentCalculator().calculateTaskSegments( session ); ProjectBuildList projectBuildList = buildListCalculator.calculateProjectBuilds( session, taskSegments ); final MojoExecutorStub mojoExecutorStub = new MojoExecutorStub(); final LifecycleWeaveBuilder builder = getWeaveBuilder( mojoExecutorStub ); final ReactorContext buildContext = createBuildContext( session ); ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus( session.getProjectDependencyGraph() ); builder.build( projectBuildList, buildContext, taskSegments, session, service, reactorBuildStatus ); LifecycleExecutionPlanCalculatorStub lifecycleExecutionPlanCalculatorStub = new LifecycleExecutionPlanCalculatorStub(); final int expected = lifecycleExecutionPlanCalculatorStub.getNumberOfExceutions( projectBuildList ); assertEquals( "All executions should be scheduled", expected, mojoExecutorStub.executions.size() ); return projectBuildList; } finally { Thread.currentThread().setContextClassLoader( loader ); } }
private ProjectBuildList getProjectBuildList() throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); return ProjectDependencyGraphStub.getProjectBuildList( session ); }
public void testConcurrencyGraphPrimaryVersion() throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { ProjectDependencyGraph dependencyGraph = new ProjectDependencyGraphStub(); final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); ConcurrencyDependencyGraph graph = new ConcurrencyDependencyGraph( getProjectBuildList( session ), dependencyGraph ); final List<MavenProject> projectBuilds = graph.getRootSchedulableBuilds(); assertEquals( 1, projectBuilds.size() ); assertEquals( A, projectBuilds.get( 0 ) ); final List<MavenProject> subsequent = graph.markAsFinished( A ); assertEquals( 2, subsequent.size() ); assertEquals( ProjectDependencyGraphStub.B, subsequent.get( 0 ) ); assertEquals( C, subsequent.get( 1 ) ); final List<MavenProject> bDescendants = graph.markAsFinished( B ); assertEquals( 1, bDescendants.size() ); assertEquals( Y, bDescendants.get( 0 ) ); final List<MavenProject> cDescendants = graph.markAsFinished( C ); assertEquals( 2, cDescendants.size() ); assertEquals( X, cDescendants.get( 0 ) ); assertEquals( Z, cDescendants.get( 1 ) ); }
public static ProjectBuildList getProjectBuildList( MavenSession session ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final List<ProjectSegment> list = getProjectBuilds( session ); return new ProjectBuildList( list ); }
private static ProjectSegment createProjectBuild( MavenProject project, MavenSession session, TaskSegment taskSegment ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final MavenSession session1 = session.clone(); return new ProjectSegment( project, taskSegment, session1 ); }
public int getNumberOfExceutions( ProjectBuildList projectBuildList ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { int result = 0; for ( ProjectSegment projectBuild : projectBuildList ) { MavenExecutionPlan plan = calculateExecutionPlan( projectBuild.getSession(), projectBuild.getProject(), projectBuild.getTaskSegment().getTasks() ); result += plan.size(); } return result; }
public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { // Maybe do something ? }
public static MavenExecutionPlan getProjectBExecutionPlan() throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException { List<MojoExecution> me = new ArrayList<MojoExecution>(); me.add( createMojoExecution( "enforce", "enforce-versions", VALIDATE ) ); me.add( createMojoExecution( "resources", "default-resources", PROCESS_RESOURCES ) ); me.add( createMojoExecution( "compile", "default-compile", COMPILE ) ); me.add( createMojoExecution( "testResources", "default-testResources", PROCESS_TEST_RESOURCES ) ); me.add( createMojoExecution( "testCompile", "default-testCompile", TEST_COMPILE ) ); me.add( createMojoExecution( "test", "default-test", TEST ) ); return createExecutionPlan( ProjectDependencyGraphStub.B.getExecutionProject(), me ); }
private static MavenExecutionPlan createExecutionPlan( MavenProject project, List<MojoExecution> mojoExecutions ) throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { final List<ExecutionPlanItem> planItemList = DefaultSchedulesStub.createDefaultSchedules().createExecutionPlanItem( project, mojoExecutions ); return new MavenExecutionPlan( planItemList, DefaultLifecyclesStub.createDefaultLifecycles() ); }
MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException;
public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException { List<TaskSegment> taskSegments = new ArrayList<TaskSegment>( tasks.size() ); TaskSegment currentSegment = null; for ( String task : tasks ) { if ( isGoalSpecification( task ) ) { // "pluginPrefix:goal" or "groupId:artifactId[:version]:goal" lifecyclePluginResolver.resolveMissingPluginVersions( session.getTopLevelProject(), session ); MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor( task, session, session.getTopLevelProject() ); boolean aggregating = mojoDescriptor.isAggregator() || !mojoDescriptor.isProjectRequired(); if ( currentSegment == null || currentSegment.isAggregating() != aggregating ) { currentSegment = new TaskSegment( aggregating ); taskSegments.add( currentSegment ); } currentSegment.getTasks().add( new GoalTask( task ) ); } else { // lifecycle phase if ( currentSegment == null || currentSegment.isAggregating() ) { currentSegment = new TaskSegment( false ); taskSegments.add( currentSegment ); } currentSegment.getTasks().add( new LifecycleTask( task ) ); } } return taskSegments; }
private void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session, MavenProject project, Collection<MojoDescriptor> alreadyForkedExecutions ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( !mojoDescriptor.isForking() ) { return; } if ( !alreadyForkedExecutions.add( mojoDescriptor ) ) { return; } List<MavenProject> forkedProjects = LifecycleDependencyResolver.getProjects( project, session, mojoDescriptor.isAggregator() ); for ( MavenProject forkedProject : forkedProjects ) { if ( forkedProject != project ) { lifecyclePluginResolver.resolveMissingPluginVersions( forkedProject, session ); } List<MojoExecution> forkedExecutions; if ( StringUtils.isNotEmpty( mojoDescriptor.getExecutePhase() ) ) { forkedExecutions = calculateForkedLifecycle( mojoExecution, session, forkedProject, alreadyForkedExecutions ); } else { forkedExecutions = calculateForkedGoal( mojoExecution, session, forkedProject, alreadyForkedExecutions ); } mojoExecution.setForkedExecutions( BuilderCommon.getKey( forkedProject ), forkedExecutions ); } alreadyForkedExecutions.remove( mojoDescriptor ); }
List<TaskSegment> calculateTaskSegments( MavenSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException;
public List<TaskSegment> calculateTaskSegments( MavenSession session, List<String> tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException;
public MavenExecutionPlan resolveBuildPlan( MavenSession session, MavenProject project, TaskSegment taskSegment, Set<Artifact> projectArtifacts ) throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException, LifecycleExecutionException { MavenExecutionPlan executionPlan = lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, project, taskSegment.getTasks() ); lifecycleDebugLogger.debugProjectPlan( project, executionPlan ); if ( session.getRequest().isThreadConfigurationPresent() ) { final Set<Plugin> unsafePlugins = executionPlan.getNonThreadSafePlugins(); if ( !unsafePlugins.isEmpty() ) { logger.warn( "*****************************************************************" ); logger.warn( "* Your build is requesting parallel execution, but project *" ); logger.warn( "* contains the following plugin(s) that have goals not marked *" ); logger.warn( "* as @threadSafe to support parallel building. *" ); logger.warn( "* While this /may/ work fine, please look for plugin updates *" ); logger.warn( "* and/or request plugins be made thread-safe. *" ); logger.warn( "* If reporting an issue, report it against the plugin in *" ); logger.warn( "* question, not against maven-core *" ); logger.warn( "*****************************************************************" ); if ( logger.isDebugEnabled() ) { final Set<MojoDescriptor> unsafeGoals = executionPlan.getNonThreadSafeMojos(); logger.warn( "The following goals are not marked @threadSafe in " + project.getName() + ":" ); for ( MojoDescriptor unsafeGoal : unsafeGoals ) { logger.warn( unsafeGoal.getId() ); } } else { logger.warn( "The following plugins are not marked @threadSafe in " + project.getName() + ":" ); for ( Plugin unsafePlugin : unsafePlugins ) { logger.warn( unsafePlugin.getId() ); } logger.warn( "Enable debug to see more precisely which goals are not marked @threadSafe." ); } logger.warn( "*****************************************************************" ); } } return executionPlan; }