mirror of https://github.com/apache/maven.git
[MNG-7720] Wrong build order of forked projects (#1040)
The original fix MNG-7672 matched the "scope" but missed the "order". `project.collectedProjects` are in order as loaded (POM order), is not topologically sorted. Fix is to use DAG of projects, ask for downstream projects (will return more then we need but sorted) and narrow that list to only contain collected projects. --- https://issues.apache.org/jira/browse/MNG-7720
This commit is contained in:
parent
bec19ec41d
commit
1ffd68b802
|
@ -90,7 +90,11 @@ public class LifecycleDependencyResolver {
|
|||
|
||||
public static List<MavenProject> getProjects(MavenProject project, MavenSession session, boolean aggregator) {
|
||||
if (aggregator && project.getCollectedProjects() != null) {
|
||||
return getProjectAndSubModules(project).collect(Collectors.toList());
|
||||
List<MavenProject> projectAndSubmodules =
|
||||
getProjectAndSubModules(project).collect(Collectors.toList()); // not sorted but what we need
|
||||
return session.getProjects().stream() // sorted all
|
||||
.filter(projectAndSubmodules::contains)
|
||||
.collect(Collectors.toList()); // sorted and filtered to what we need
|
||||
} else {
|
||||
return Collections.singletonList(project);
|
||||
}
|
||||
|
@ -99,7 +103,10 @@ public class LifecycleDependencyResolver {
|
|||
private static Stream<MavenProject> getProjectAndSubModules(MavenProject project) {
|
||||
return Stream.concat(
|
||||
Stream.of(project),
|
||||
project.getCollectedProjects().stream().flatMap(LifecycleDependencyResolver::getProjectAndSubModules));
|
||||
project.getCollectedProjects() == null
|
||||
? Stream.empty()
|
||||
: project.getCollectedProjects().stream()
|
||||
.flatMap(LifecycleDependencyResolver::getProjectAndSubModules));
|
||||
}
|
||||
|
||||
public void resolveProjectDependencies(
|
||||
|
|
Loading…
Reference in New Issue