Skip to content

Commit

Permalink
[MNG-7720] Wrong build order of forked projects (#1038)
Browse files Browse the repository at this point in the history
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: 48cac1c

---

https://issues.apache.org/jira/browse/MNG-7720
  • Loading branch information
cstamas authored Mar 8, 2023
1 parent 528cea3 commit 57acdd4
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ public LifecycleDependencyResolver(ProjectDependenciesResolver projectDependenci

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);
}
Expand All @@ -99,7 +103,10 @@ public static List<MavenProject> getProjects(MavenProject project, MavenSession
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(
Expand Down

0 comments on commit 57acdd4

Please sign in to comment.