mirror of https://github.com/apache/maven.git
[MNG-7720] Wrong build order of forked projects (#1038)
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.
Related commit: 48cac1c003
---
https://issues.apache.org/jira/browse/MNG-7720
This commit is contained in:
parent
528cea3ad9
commit
57acdd41b4
|
@ -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