org.apache.maven.execution.ProjectDependencyGraph Java Examples

The following examples show how to use org.apache.maven.execution.ProjectDependencyGraph. 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: MavenSessionMock.java    From gitflow-incremental-builder with MIT License 6 votes vote down vote up
public static MavenSession get(Path workDir, Properties topLevelProjectProperties) throws Exception {
    PomFinder finder = new PomFinder();
    Files.walkFileTree(workDir, finder);
    List<MavenProject> projects = finder.projects.stream()
            .sorted()
            .map(MavenSessionMock::createProject)
            .collect(Collectors.toList());

    MavenProject topLevelProject = projects.get(0);
    topLevelProject.getModel().setProperties(topLevelProjectProperties);
    MavenSession mavenSession = mock(MavenSession.class, withSettings().lenient());
    when(mavenSession.getCurrentProject()).thenReturn(topLevelProject);
    MavenExecutionRequest request = mock(MavenExecutionRequest.class);
    when(mavenSession.getRequest()).thenReturn(request);
    when(mavenSession.getAllProjects()).thenReturn(projects);
    when(mavenSession.getProjects()).thenReturn(projects);
    when(mavenSession.getTopLevelProject()).thenReturn(topLevelProject);
    ProjectDependencyGraph dependencyGraphMock = mock(ProjectDependencyGraph.class);
    when(mavenSession.getProjectDependencyGraph()).thenReturn(dependencyGraphMock);
    return mavenSession;
}
 
Example #2
Source File: ReactorBuildQueue.java    From takari-smart-builder with Apache License 2.0 6 votes vote down vote up
public ReactorBuildQueue(Collection<MavenProject> projects,
    ProjectDependencyGraph dependencyGraph) {
  this.dependencyGraph = dependencyGraph;

  final Set<MavenProject> rootProjects = new HashSet<MavenProject>();

  for (MavenProject project : projects) {
    if (dependencyGraph.getUpstreamProjects(project, false).isEmpty()) {
      rootProjects.add(project);
    } else {
      blockedProjects.add(project);
    }
  }

  this.rootProjects = ImmutableSet.copyOf(rootProjects);
  this.projects = ImmutableSet.copyOf(projects);
}
 
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: MavenLifecycleParticipantTest.java    From gitflow-incremental-builder with MIT License 5 votes vote down vote up
@BeforeEach
void before() {
    MavenProject mockTLProject = mock(MavenProject.class);
    when(mockTLProject.getProperties()).thenReturn(projectProperties);
    when(mavenSessionMock.getTopLevelProject()).thenReturn(mockTLProject);

    when(mavenSessionMock.getRequest()).thenReturn(mock(MavenExecutionRequest.class));

    when(mavenSessionMock.getProjectDependencyGraph()).thenReturn(mock(ProjectDependencyGraph.class));

    Whitebox.setInternalState(underTest, new Configuration.Provider(mavenSessionMock));
}
 
Example #5
Source File: ReactorBuildStats.java    From takari-smart-builder with Apache License 2.0 4 votes vote down vote up
public String renderCriticalPath(ProjectDependencyGraph graph) {
  return renderCriticalPath(DependencyGraph.fromMaven(graph), p -> projectGA(p));
}
 
Example #6
Source File: ProjectComparator.java    From takari-smart-builder with Apache License 2.0 4 votes vote down vote up
public static Comparator<MavenProject> create(MavenSession session) {
  final ProjectDependencyGraph dependencyGraph = session.getProjectDependencyGraph();
  return create0(DependencyGraph.fromMaven(dependencyGraph), ImmutableMap.of(), p -> id(p));
}