1 | |
package org.apache.maven.artifact.ant; |
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.resolver.ResolutionListener; |
24 | |
import org.apache.maven.artifact.versioning.VersionRange; |
25 | |
import org.apache.tools.ant.Project; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
public class AntResolutionListener |
34 | |
implements ResolutionListener |
35 | |
{ |
36 | 0 | private String indent = ""; |
37 | |
|
38 | |
private final Project project; |
39 | |
|
40 | |
private int logLevel; |
41 | |
|
42 | |
public AntResolutionListener( Project project, boolean verbose ) |
43 | 0 | { |
44 | 0 | this.project = project; |
45 | 0 | logLevel = verbose ? Project.MSG_INFO : Project.MSG_VERBOSE; |
46 | 0 | } |
47 | |
|
48 | |
public void testArtifact( Artifact node ) |
49 | |
{ |
50 | 0 | } |
51 | |
|
52 | |
public void startProcessChildren( Artifact artifact ) |
53 | |
{ |
54 | 0 | indent += " "; |
55 | 0 | } |
56 | |
|
57 | |
public void endProcessChildren( Artifact artifact ) |
58 | |
{ |
59 | 0 | indent = indent.substring( 2 ); |
60 | 0 | } |
61 | |
|
62 | |
public void includeArtifact( Artifact artifact ) |
63 | |
{ |
64 | 0 | project.log( indent + artifact + " (selected)", logLevel ); |
65 | 0 | } |
66 | |
|
67 | |
public void omitForNearer( Artifact omitted, Artifact kept ) |
68 | |
{ |
69 | 0 | project.log( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")", logLevel ); |
70 | 0 | } |
71 | |
|
72 | |
public void omitForCycle( Artifact omitted ) |
73 | |
{ |
74 | 0 | project.log( indent + omitted + " (removed - causes a cycle in the graph)", logLevel ); |
75 | 0 | } |
76 | |
|
77 | |
public void updateScope( Artifact artifact, String scope ) |
78 | |
{ |
79 | 0 | project.log( indent + artifact + " (setting scope to: " + scope + ")", logLevel ); |
80 | 0 | } |
81 | |
|
82 | |
public void updateScopeCurrentPom( Artifact artifact, String scope ) |
83 | |
{ |
84 | 0 | project.log( indent + artifact + " (not setting scope to: " + scope + "; local scope " + artifact.getScope() |
85 | |
+ " wins)", logLevel ); |
86 | 0 | } |
87 | |
|
88 | |
public void selectVersionFromRange( Artifact artifact ) |
89 | |
{ |
90 | 0 | project.log( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " |
91 | |
+ artifact.getVersionRange() + ")", logLevel ); |
92 | 0 | } |
93 | |
|
94 | |
public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ) |
95 | |
{ |
96 | 0 | project.log( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " |
97 | |
+ replacement.getVersionRange() + " to: " + newRange + " )", logLevel ); |
98 | 0 | } |
99 | |
|
100 | |
public void manageArtifact( Artifact artifact, Artifact replacement ) |
101 | |
{ |
102 | 0 | String msg = indent + artifact; |
103 | 0 | msg += " ("; |
104 | 0 | if ( replacement.getVersion() != null ) |
105 | |
{ |
106 | 0 | msg += "applying version: " + replacement.getVersion() + ";"; |
107 | |
} |
108 | 0 | if ( replacement.getScope() != null ) |
109 | |
{ |
110 | 0 | msg += "applying scope: " + replacement.getScope(); |
111 | |
} |
112 | 0 | msg += ")"; |
113 | 0 | project.log( msg, logLevel ); |
114 | 0 | } |
115 | |
} |