1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.impl.resolver;
20
21 import java.util.stream.Collectors;
22
23 import org.eclipse.aether.RequestTrace;
24 import org.eclipse.aether.collection.CollectRequest;
25 import org.eclipse.aether.collection.CollectStepData;
26 import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
27 import org.eclipse.aether.resolution.ArtifactRequest;
28 import org.eclipse.aether.resolution.DependencyRequest;
29
30
31
32
33 public final class RequestTraceHelper {
34
35
36
37
38
39 public static String interpretTrace(boolean detailed, RequestTrace requestTrace) {
40 while (requestTrace != null) {
41 Object data = requestTrace.getData();
42 if (data instanceof DependencyRequest request) {
43 return "dependency resolution for " + request;
44 } else if (data instanceof CollectRequest request) {
45 return "dependency collection for " + request;
46 } else if (data instanceof CollectStepData stepData) {
47 String msg = "dependency collection step for " + stepData.getContext();
48 if (detailed) {
49 msg += ". Path to offending node from root:\n";
50 msg += stepData.getPath().stream()
51 .map(n -> " -> " + n.toString())
52 .collect(Collectors.joining("\n"));
53 msg += "\n => " + stepData.getNode();
54 }
55 return msg;
56 } else if (data instanceof ArtifactDescriptorRequest request) {
57 return "artifact descriptor request for " + request.getArtifact();
58 } else if (data instanceof ArtifactRequest request) {
59 return "artifact request for " + request.getArtifact();
60
61
62
63 }
64 requestTrace = requestTrace.getParent();
65 }
66
67 return "n/a";
68 }
69 }