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