org.apache.maven.lifecycle.internal.TaskSegment Java Examples

The following examples show how to use org.apache.maven.lifecycle.internal.TaskSegment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmartBuilderImpl.java    From takari-smart-builder with Apache License 2.0 6 votes vote down vote up
SmartBuilderImpl(LifecycleModuleBuilder lifecycleModuleBuilder, MavenSession session,
    ReactorContext reactorContext, TaskSegment taskSegment, Set<MavenProject> projects) {
  this.lifecycleModuleBuilder = lifecycleModuleBuilder;
  this.rootSession = session;
  this.reactorContext = reactorContext;
  this.taskSegment = taskSegment;

  this.degreeOfConcurrency = Integer.valueOf(session.getRequest().getDegreeOfConcurrency());

  final Comparator<MavenProject> projectComparator = ProjectComparator.create(session);

  this.reactorBuildQueue = new ReactorBuildQueue(projects, session.getProjectDependencyGraph());
  this.executor = new ProjectExecutorService(degreeOfConcurrency, projectComparator);

  this.stats = ReactorBuildStats.create(projects);
}
 
Example #2
Source File: IncrementalModuleBuilderImpl.java    From incremental-module-builder with Apache License 2.0 5 votes vote down vote up
IncrementalModuleBuilderImpl( List<MavenProject> selectedProjects, LifecycleModuleBuilder lifecycleModuleBuilder,
                              MavenSession session, ReactorContext reactorContext, List<TaskSegment> taskSegments )
{

    this.lifecycleModuleBuilder =
        Objects.requireNonNull( lifecycleModuleBuilder, "lifecycleModuleBuilder is not allowed to be null." );
    this.mavenSession = Objects.requireNonNull( session, "session is not allowed to be null." );
    this.taskSegments = Objects.requireNonNull( taskSegments, "taskSegements is not allowed to be null" );
    this.reactorContext = Objects.requireNonNull( reactorContext, "reactorContext is not allowed to be null." );

    ProjectDependencyGraph projectDependencyGraph = session.getProjectDependencyGraph();

    List<MavenProject> intermediateResult = new LinkedList<>();

    for ( MavenProject selectedProject : selectedProjects )
    {
        intermediateResult.add( selectedProject );
        // Up or downstream ? (-amd)
        intermediateResult.addAll( projectDependencyGraph.getDownstreamProjects( selectedProject, true ) );
        // TODO: Need to think about this? -am ?
        // intermediateResult.addAll(projectDependencyGraph.getUpstreamProjects(selectedProject,
        // true));
    }

    List<MavenProject> result = new LinkedList<>();

    for ( MavenProject project : intermediateResult )
    {
        if ( !result.contains( project ) )
        {
            result.add( project );
        }
    }

    this.projects = result;

}
 
Example #3
Source File: GenerateBomMojo.java    From sundrio with Apache License 2.0 5 votes vote down vote up
private void build(MavenSession session, MavenProject project, List<MavenProject> allProjects, GoalSet goals) throws MojoExecutionException {
    session.setProjects(allProjects);
    ProjectIndex projectIndex = new ProjectIndex(session.getProjects());
    try {
        ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus(new BomDependencyGraph(session.getProjects()));
        ReactorContext reactorContext = new ReactorContextFactory(new MavenVersion(mavenVersion)).create(session.getResult(), projectIndex, Thread.currentThread().getContextClassLoader(),
                reactorBuildStatus, builder);
        List<TaskSegment> segments = segmentCalculator.calculateTaskSegments(session);
        for (TaskSegment segment : segments) {
            builder.buildProject(session, reactorContext, project, filterSegment(segment, goals));
        }
    } catch (Throwable t) {
        throw new MojoExecutionException("Error building generated bom:" + project.getArtifactId(), t);
    }
}
 
Example #4
Source File: GenerateBomMojo.java    From sundrio with Apache License 2.0 5 votes vote down vote up
private static TaskSegment filterSegment(TaskSegment segment, GoalSet goals) {
    List<Object> filtered = new ArrayList<Object>();

    Set<String> includes = goals.getIncludes();
    Set<String> excludes = goals.getExcludes();

    for (Object obj : segment.getTasks()) {
        String name = Reflections.readAnyField(obj, "pluginGoal", "lifecyclePhase");

        if (!excludes.contains(name) && (includes.contains(name) || includes.isEmpty())) {
            filtered.add(obj);
        }
    }
    return new TaskSegment(segment.isAggregating(), filtered.toArray());
}