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 request) {
46 return "dependency resolution for " + request;
47 } else if (data instanceof CollectRequest request) {
48 return "dependency collection for " + request;
49 } else if (data instanceof CollectStepData stepData) {
50 String msg = "dependency collection step for " + stepData.getContext();
51 if (detailed) {
52 msg += ". Path to offending node from root:\n";
53 msg += stepData.getPath().stream()
54 .map(n -> " -> " + n.toString())
55 .collect(Collectors.joining("\n"));
56 msg += "\n => " + stepData.getNode();
57 }
58 return msg;
59 } else if (data instanceof ArtifactDescriptorRequest request) {
60 return "artifact descriptor request for " + request.getArtifact();
61 } else if (data instanceof ArtifactRequest request) {
62 return "artifact request for " + request.getArtifact();
63 } else if (data instanceof Plugin plugin) {
64 return "plugin request " + plugin.getId();
65 }
66 requestTrace = requestTrace.getParent();
67 }
68
69 return "n/a";
70 }
71 }