Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort dependency tree root nodes #3825

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public P2DependencyTreeGenerator(InstallableUnitGenerator generator, TychoProjec
* Calculates and returns the dependency tree of the given Maven project. The list that is
* returned by this method corresponds to the IUs which are directly required by the given
* project.
*
*
* @param project
* One of the Maven projects of the current reactor build. If this project is not a
* Tycho project (e.g. the parent pom), an empty list is returned.
Expand Down Expand Up @@ -107,7 +107,7 @@ public List<DependencyTreeNode> buildDependencyTree(MavenProject project, Set<II
* parent. Each IU is unique and must only appear once in the dependency tree.
*/
public static class DependencyTreeNode {
private static final Comparator<IInstallableUnit> COMPARATOR = Comparator.comparing(IInstallableUnit::getId,
public static final Comparator<IInstallableUnit> COMPARATOR = Comparator.comparing(IInstallableUnit::getId,
String.CASE_INSENSITIVE_ORDER);
private final IInstallableUnit iu;
private final IRequirement satisfies;
Expand Down Expand Up @@ -144,7 +144,7 @@ public String toString() {
* each IU of {@code initial}. The children of a node correspond to all IUs that are
* (directly) required by the parent IU. Each IU in {@code units} only appears once, even if
* it required by multiple IUs.
*
*
* @param initial
* The "direct" IUs referenced by a given artifact.
* @param units
Expand Down Expand Up @@ -175,7 +175,7 @@ private static List<DependencyTreeNode> create(List<IInstallableUnit> initial, S
* is found, it is removed from {@code units}, meaning that each IU can only show up once in
* the dependency tree. The children of each node are sorted lexicographically according to
* {@link #COMPARATOR}.
*
*
* @param node
* The (intermediate) head of the dependency tree.
* @param units
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.eclipse.tycho.plugins.p2;

import java.util.AbstractMap.SimpleEntry;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -76,14 +77,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
throw new MojoFailureException(e);
}

for (DependencyTreeNode rootNode : dependencyTree) {
for (DependencyTreeNode rootNode : dependencyTree.stream()
.sorted(Comparator.comparing(DependencyTreeNode::getInstallableUnit, DependencyTreeNode.COMPARATOR))
.toList()) {
printUnit(rootNode, projectMap, 0);
}

if (!unmapped.isEmpty()) {
getLog().info("Units that cannot be matched to any requirement:");
for (IInstallableUnit unit : unmapped) {
getLog().info(unit.toString());
for (IInstallableUnit unit : unmapped.stream().sorted(DependencyTreeNode.COMPARATOR).toList()) {
getLog().info(" " + unit.toString());
}
}

Expand Down