Skip to content

Commit

Permalink
[MNG-7720] Wrong build order of forked projects (#1039)
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.

---

https://issues.apache.org/jira/browse/MNG-7720
  • Loading branch information
cstamas committed Mar 8, 2023
1 parent a0f460c commit ad74f9e
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -97,9 +98,18 @@ public static List<MavenProject> getProjects( MavenProject project, MavenSession
{
if ( aggregator && project.getCollectedProjects() != null )
{
List<MavenProject> projects = new ArrayList<>();
addProjectAndSubModules( projects, project );
return projects;
List<MavenProject> sortedProjects = new ArrayList<>( session.getProjects() ); // sorted but all
List<MavenProject> projectAndSubmodules = new ArrayList<>();
addProjectAndSubModules( projectAndSubmodules, project ); // not sorted but what we need
Iterator<MavenProject> sortedProjectsIterator = sortedProjects.listIterator();
while ( sortedProjectsIterator.hasNext() )
{
if ( !projectAndSubmodules.contains( sortedProjectsIterator.next() ) )
{
sortedProjectsIterator.remove();
}
}
return sortedProjects;
}
else
{
Expand Down

0 comments on commit ad74f9e

Please sign in to comment.