1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.artifact.resolver;
20
21 import java.util.HashSet;
22 import java.util.Objects;
23 import java.util.Set;
24
25 import org.apache.maven.artifact.Artifact;
26 import org.apache.maven.artifact.versioning.VersionRange;
27 import org.codehaus.plexus.logging.Logger;
28
29
30
31
32
33 @Deprecated
34 public class DebugResolutionListener implements ResolutionListener, ResolutionListenerForDepMgmt {
35 private Logger logger;
36
37 private String indent = "";
38
39 private static Set<Artifact> ignoredArtifacts = new HashSet<>();
40
41 public DebugResolutionListener(Logger logger) {
42 this.logger = logger;
43 }
44
45 public void testArtifact(Artifact node) {}
46
47 public void startProcessChildren(Artifact artifact) {
48 indent += " ";
49 }
50
51 public void endProcessChildren(Artifact artifact) {
52 indent = indent.substring(2);
53 }
54
55 public void includeArtifact(Artifact artifact) {
56 logger.debug(indent + artifact + " (selected for " + artifact.getScope() + ")");
57 }
58
59 public void omitForNearer(Artifact omitted, Artifact kept) {
60 String omittedVersion = omitted.getVersion();
61 String keptVersion = kept.getVersion();
62
63 if (!Objects.equals(omittedVersion, keptVersion)) {
64 logger.debug(indent + omitted + " (removed - nearer found: " + keptVersion + ")");
65 }
66 }
67
68 public void omitForCycle(Artifact omitted) {
69 logger.debug(indent + omitted + " (removed - causes a cycle in the graph)");
70 }
71
72 public void updateScopeCurrentPom(Artifact artifact, String ignoredScope) {
73 logger.debug(indent + artifact + " (not setting artifactScope to: " + ignoredScope + "; local artifactScope "
74 + artifact.getScope() + " wins)");
75
76
77 if (!ignoredArtifacts.contains(artifact)) {
78 logger.warn("\n\tArtifact " + artifact + " retains local artifactScope '" + artifact.getScope()
79 + "' overriding broader artifactScope '" + ignoredScope + "'\n"
80 + "\tgiven by a dependency. If this is not intended, modify or remove the local artifactScope.\n");
81 ignoredArtifacts.add(artifact);
82 }
83 }
84
85 public void updateScope(Artifact artifact, String scope) {
86 logger.debug(indent + artifact + " (setting artifactScope to: " + scope + ")");
87 }
88
89 public void selectVersionFromRange(Artifact artifact) {
90 logger.debug(indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: "
91 + artifact.getVersionRange() + ")");
92 }
93
94 public void restrictRange(Artifact artifact, Artifact replacement, VersionRange newRange) {
95 logger.debug(indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: "
96 + replacement.getVersionRange() + " to: " + newRange + " )");
97 }
98
99
100
101
102
103
104
105 public void manageArtifact(Artifact artifact, Artifact replacement) {
106 String msg = indent + artifact;
107 msg += " (";
108 if (replacement.getVersion() != null) {
109 msg += "applying version: " + replacement.getVersion() + ";";
110 }
111 if (replacement.getScope() != null) {
112 msg += "applying artifactScope: " + replacement.getScope();
113 }
114 msg += ")";
115 logger.debug(msg);
116 }
117
118 public void manageArtifactVersion(Artifact artifact, Artifact replacement) {
119
120 if (!replacement.getVersion().equals(artifact.getVersion())) {
121 String msg = indent + artifact + " (applying version: " + replacement.getVersion() + ")";
122 logger.debug(msg);
123 }
124 }
125
126 public void manageArtifactScope(Artifact artifact, Artifact replacement) {
127
128 if (!replacement.getScope().equals(artifact.getScope())) {
129 String msg = indent + artifact + " (applying artifactScope: " + replacement.getScope() + ")";
130 logger.debug(msg);
131 }
132 }
133
134 public void manageArtifactSystemPath(Artifact artifact, Artifact replacement) {
135
136 if (!replacement.getScope().equals(artifact.getScope())) {
137 String msg = indent + artifact + " (applying system path: " + replacement.getFile() + ")";
138 logger.debug(msg);
139 }
140 }
141 }