1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl.scope;
20
21 import java.util.Comparator;
22 import java.util.stream.Collectors;
23
24 import org.eclipse.aether.impl.scope.BuildScope;
25 import org.eclipse.aether.impl.scope.ScopeManagerConfiguration;
26 import org.eclipse.aether.scope.ResolutionScope;
27
28 import static org.eclipse.aether.impl.scope.BuildScopeQuery.all;
29
30
31
32
33 public final class ScopeManagerDump {
34
35
36
37
38 public static void dump(ScopeManagerConfiguration configuration) {
39 new ScopeManagerDump(configuration);
40 }
41
42 private ScopeManagerDump(ScopeManagerConfiguration configuration) {
43 ScopeManagerImpl scopeManager = new ScopeManagerImpl(configuration);
44 System.out.println();
45 dumpBuildScopes(scopeManager);
46 System.out.println();
47 dumpDependencyScopes(scopeManager);
48 System.out.println();
49 dumpDependencyScopeDerives(scopeManager);
50 System.out.println();
51 dumpResolutionScopes(scopeManager);
52 }
53
54 private void dumpBuildScopes(ScopeManagerImpl scopeManager) {
55 System.out.println(scopeManager.getId() + " defined build scopes:");
56 scopeManager.getBuildScopeSource().query(all()).stream()
57 .sorted(Comparator.comparing(BuildScope::order))
58 .forEach(s -> System.out.println(s.getId() + " (order=" + s.order() + ")"));
59 }
60
61 private void dumpDependencyScopes(ScopeManagerImpl scopeManager) {
62 System.out.println(scopeManager.getId() + " defined dependency scopes:");
63 scopeManager.getDependencyScopeUniverse().stream()
64 .sorted(Comparator.comparing(scopeManager::getDependencyScopeWidth)
65 .reversed())
66 .forEach(s -> {
67 System.out.println(s + " (width=" + scopeManager.getDependencyScopeWidth(s) + ")");
68 System.out.println(" Query : " + scopeManager.getPresence(s));
69 System.out.println(" Presence: "
70 + scopeManager.getBuildScopeSource().query(scopeManager.getPresence(s)).stream()
71 .map(BuildScope::getId)
72 .collect(Collectors.toSet()));
73 System.out.println(" Main project scope: "
74 + scopeManager
75 .getDependencyScopeMainProjectBuildScope(s)
76 .map(BuildScope::getId)
77 .orElse("null"));
78 });
79 }
80
81 private void dumpDependencyScopeDerives(ScopeManagerImpl scopeManager) {
82 System.out.println(scopeManager.getId() + " defined dependency derive matrix:");
83 ManagedScopeDeriver deriver = new ManagedScopeDeriver(scopeManager);
84 scopeManager.getDependencyScopeUniverse().stream()
85 .sorted(Comparator.comparing(scopeManager::getDependencyScopeWidth)
86 .reversed())
87 .forEach(parent -> scopeManager.getDependencyScopeUniverse().stream()
88 .sorted(Comparator.comparing(scopeManager::getDependencyScopeWidth)
89 .reversed())
90 .forEach(child -> System.out.println(parent.getId() + " w/ child " + child.getId() + " -> "
91 + deriver.getDerivedScope(parent.getId(), child.getId()))));
92 }
93
94 private void dumpResolutionScopes(ScopeManagerImpl scopeManager) {
95 System.out.println(scopeManager.getId() + " defined resolution scopes:");
96 scopeManager.getResolutionScopeUniverse().stream()
97 .sorted(Comparator.comparing(ResolutionScope::getId))
98 .forEach(s -> {
99 System.out.println("* " + s.getId());
100 System.out.println(" Directly included: " + scopeManager.getDirectlyIncludedLabels(s));
101 System.out.println(" Directly excluded: " + scopeManager.getDirectlyExcludedLabels(s));
102 System.out.println(" Transitively excluded: " + scopeManager.getTransitivelyExcludedLabels(s));
103 });
104 }
105 }