Skip to content

Commit

Permalink
Sort dependency tree root nodes
Browse files Browse the repository at this point in the history
Also indent the unmapped IUs for better readability.

Fixes #3817
  • Loading branch information
Bananeweizen authored and laeubi committed May 6, 2024
1 parent 7490426 commit c146887
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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

0 comments on commit c146887

Please sign in to comment.