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