1 | |
package org.apache.maven.plugin.testing.stubs; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.io.IOException; |
23 | |
import java.util.List; |
24 | |
import java.util.Map; |
25 | |
import java.util.Set; |
26 | |
|
27 | |
import org.apache.maven.artifact.Artifact; |
28 | |
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; |
29 | |
import org.apache.maven.artifact.repository.ArtifactRepository; |
30 | |
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; |
31 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionException; |
32 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; |
33 | |
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; |
34 | |
import org.apache.maven.artifact.resolver.ArtifactResolver; |
35 | |
import org.apache.maven.artifact.resolver.ResolutionListener; |
36 | |
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; |
37 | |
import org.apache.maven.plugin.testing.ArtifactStubFactory; |
38 | |
import org.apache.maven.wagon.events.TransferListener; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public class StubArtifactResolver |
47 | |
implements ArtifactResolver |
48 | |
{ |
49 | |
private boolean throwArtifactResolutionException; |
50 | |
|
51 | |
private boolean throwArtifactNotFoundException; |
52 | |
|
53 | |
private ArtifactStubFactory factory; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
public StubArtifactResolver( ArtifactStubFactory factory, boolean throwArtifactResolutionException, |
63 | |
boolean throwArtifactNotFoundException ) |
64 | 0 | { |
65 | 0 | this.throwArtifactNotFoundException = throwArtifactNotFoundException; |
66 | 0 | this.throwArtifactResolutionException = throwArtifactResolutionException; |
67 | 0 | this.factory = factory; |
68 | 0 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository ) |
76 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
77 | |
{ |
78 | 0 | if ( !this.throwArtifactNotFoundException && !this.throwArtifactResolutionException ) |
79 | |
{ |
80 | |
try |
81 | |
{ |
82 | 0 | if ( factory != null ) |
83 | |
{ |
84 | 0 | factory.setArtifactFile( artifact, factory.getWorkingDir() ); |
85 | |
} |
86 | |
} |
87 | 0 | catch ( IOException e ) |
88 | |
{ |
89 | 0 | throw new ArtifactResolutionException( "IOException: " + e.getMessage(), artifact, e ); |
90 | 0 | } |
91 | |
} |
92 | |
else |
93 | |
{ |
94 | 0 | if ( throwArtifactResolutionException ) |
95 | |
{ |
96 | 0 | throw new ArtifactResolutionException( "Catch!", artifact ); |
97 | |
} |
98 | |
|
99 | 0 | throw new ArtifactNotFoundException( "Catch!", artifact ); |
100 | |
} |
101 | 0 | } |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, |
108 | |
List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, |
109 | |
ArtifactMetadataSource source ) |
110 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
111 | |
{ |
112 | 0 | return null; |
113 | |
} |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, |
120 | |
List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, |
121 | |
ArtifactMetadataSource source, List<ResolutionListener> listeners ) |
122 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
123 | |
{ |
124 | 0 | return null; |
125 | |
} |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, |
132 | |
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, |
133 | |
ArtifactMetadataSource source, ArtifactFilter filter ) |
134 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
135 | |
{ |
136 | 0 | return null; |
137 | |
} |
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, |
144 | |
Map managedVersions, ArtifactRepository localRepository, |
145 | |
List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source ) |
146 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
147 | |
{ |
148 | 0 | return null; |
149 | |
} |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, |
156 | |
Map managedVersions, ArtifactRepository localRepository, |
157 | |
List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, |
158 | |
ArtifactFilter filter ) |
159 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
160 | |
{ |
161 | 0 | return null; |
162 | |
} |
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, |
169 | |
Map managedVersions, ArtifactRepository localRepository, |
170 | |
List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, |
171 | |
ArtifactFilter filter, List<ResolutionListener> listeners ) |
172 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
173 | |
{ |
174 | 0 | return null; |
175 | |
} |
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository ) |
183 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
184 | |
{ |
185 | |
|
186 | 0 | } |
187 | |
|
188 | |
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, |
189 | |
TransferListener downloadMonitor ) |
190 | |
throws ArtifactResolutionException, ArtifactNotFoundException |
191 | |
{ |
192 | |
|
193 | |
|
194 | 0 | } |
195 | |
|
196 | |
public ArtifactResolutionResult collect( ArtifactResolutionRequest request ) |
197 | |
{ |
198 | 0 | return null; |
199 | |
} |
200 | |
|
201 | |
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request ) |
202 | |
{ |
203 | 0 | return null; |
204 | |
} |
205 | |
} |