[MNG-7672] Fork should only execute the project and its submodules (#968)

This commit is contained in:
Guillaume Nodet 2023-01-30 15:08:08 +01:00 committed by GitHub
parent fbeefb85ab
commit 30fafa6741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -30,6 +30,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
@ -88,12 +90,18 @@ public class LifecycleDependencyResolver {
public static List<MavenProject> getProjects(MavenProject project, MavenSession session, boolean aggregator) {
if (aggregator) {
return session.getProjects();
return getProjectAndSubModules(project).collect(Collectors.toList());
} else {
return Collections.singletonList(project);
}
}
private static Stream<MavenProject> getProjectAndSubModules(MavenProject project) {
return Stream.concat(
Stream.of(project),
project.getCollectedProjects().stream().flatMap(LifecycleDependencyResolver::getProjectAndSubModules));
}
public void resolveProjectDependencies(
MavenProject project,
Collection<String> scopesToCollect,