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

The following examples show how to use org.apache.maven.lifecycle.internal.LifecycleModuleBuilder. 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: IncrementalModuleBuilder.java    From incremental-module-builder with Apache License 2.0 5 votes vote down vote up
@Inject
public IncrementalModuleBuilder( LifecycleModuleBuilder lifecycleModuleBuilder )
{
    LOGGER.info( " ------------------------------------" );
    LOGGER.info( " Maven Incremental Module Builder" );
    LOGGER.info( " Version: {}", IncrementalModuleBuilderVersion.getVersion() );
    LOGGER.debug( "     SHA: {}", IncrementalModuleBuilderVersion.getRevision() );
    LOGGER.info( " ------------------------------------" );
    this.lifecycleModuleBuilder = lifecycleModuleBuilder;
}
 
Example #3
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 #4
Source File: ReactorContextFactory.java    From sundrio with Apache License 2.0 5 votes vote down vote up
public ReactorContext create(MavenExecutionResult result, ProjectIndex index, ClassLoader classLoader, ReactorBuildStatus status, LifecycleModuleBuilder builder) {
    ReactorContext context;
    if (VERSION_3_0_0.compareTo(version) < 0) {
        throw new UnsupportedOperationException("ReactorContext is not supported in maven version:" + version);
    } else if (VERSION_3_3_0.compareTo(version) < 0) {
        context = create_3_2_x(result, index, classLoader, status);
    } else {
        context = create_3_3_x(result, index, classLoader, status, builder);
    }

    if (context == null) {
        throw new IllegalStateException("Unable to create ReactorContext");
    }
    return context;
}
 
Example #5
Source File: ReactorContextFactory.java    From sundrio with Apache License 2.0 5 votes vote down vote up
private static ReactorContext create_3_3_x(MavenExecutionResult result, ProjectIndex index, ClassLoader classLoader, ReactorBuildStatus status, LifecycleModuleBuilder builder) {
    try {
        Constructor<ReactorContext> constructor = (Constructor<ReactorContext>) ReactorContext.class.getDeclaredConstructors()[0];
        return constructor.newInstance(result, index, classLoader, status, Reflections.getMemento(builder));
    } catch (Throwable t) {
        throw new RuntimeException("Could not create ReactorContext.", t);
    }
}
 
Example #6
Source File: Reflections.java    From sundrio with Apache License 2.0 5 votes vote down vote up
/**
 * Read using reflection the SessionScope of the {@link org.apache.maven.lifecycle.internal.LifecycleModuleBuilder}.
 * @param source    The {@link org.apache.maven.lifecycle.internal.LifecycleModuleBuilder}
 * @return          The {@link org.apache.maven.session.scope.internal.SessionScope.Memento}
 * @throws Exception
 */
static Object getMemento(LifecycleModuleBuilder source) throws Exception {
    Field sessionScopeFiled = source.getClass().getDeclaredField("sessionScope");
    sessionScopeFiled.setAccessible(true);
    Object sessionScope = sessionScopeFiled.get(source);
    Method mementoMethod = sessionScope.getClass().getDeclaredMethod("memento");
    mementoMethod.setAccessible(true);
    return mementoMethod.invoke(sessionScope);
}
 
Example #7
Source File: SmartBuilder.java    From takari-smart-builder with Apache License 2.0 4 votes vote down vote up
@Inject
public SmartBuilder(LifecycleModuleBuilder moduleBuilder) {
  this.moduleBuilder = moduleBuilder;
}