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 java.util.ArrayList;
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.repository.ArtifactRepository;
29 import org.apache.maven.artifact.repository.RepositoryCache;
30 import org.apache.maven.artifact.repository.RepositoryRequest;
31 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
32 import org.apache.maven.settings.Mirror;
33 import org.apache.maven.settings.Proxy;
34 import org.apache.maven.settings.Server;
35
36
37
38
39
40
41
42 public class ArtifactResolutionRequest
43 implements RepositoryRequest
44 {
45
46 private Artifact artifact;
47
48
49
50
51 private Set<Artifact> artifactDependencies;
52
53 private ArtifactRepository localRepository;
54
55 private List<ArtifactRepository> remoteRepositories;
56
57 private ArtifactFilter collectionFilter;
58
59 private ArtifactFilter resolutionFilter;
60
61
62 private List<ResolutionListener> listeners = new ArrayList<ResolutionListener>();
63
64
65 private Map<String, Artifact> managedVersionMap;
66
67 private boolean resolveRoot = true;
68
69 private boolean resolveTransitively = false;
70
71 private boolean offline;
72
73 private boolean forceUpdate;
74
75 private List<Server> servers;
76
77 private List<Mirror> mirrors;
78
79 private List<Proxy> proxies;
80
81 public ArtifactResolutionRequest()
82 {
83
84 }
85
86 public ArtifactResolutionRequest( RepositoryRequest request )
87 {
88 setLocalRepository( request.getLocalRepository() );
89 setRemoteRepositories( request.getRemoteRepositories() );
90 setOffline( request.isOffline() );
91 setForceUpdate( request.isForceUpdate() );
92 }
93
94 public Artifact getArtifact()
95 {
96 return artifact;
97 }
98
99 public ArtifactResolutionRequest setArtifact( Artifact artifact )
100 {
101 this.artifact = artifact;
102
103 return this;
104 }
105
106 public ArtifactResolutionRequest setArtifactDependencies( Set<Artifact> artifactDependencies )
107 {
108 this.artifactDependencies = artifactDependencies;
109
110 return this;
111 }
112
113 public Set<Artifact> getArtifactDependencies()
114 {
115 return artifactDependencies;
116 }
117
118 public ArtifactRepository getLocalRepository()
119 {
120 return localRepository;
121 }
122
123 public ArtifactResolutionRequest setLocalRepository( ArtifactRepository localRepository )
124 {
125 this.localRepository = localRepository;
126
127 return this;
128 }
129
130 public List<ArtifactRepository> getRemoteRepositories()
131 {
132 return remoteRepositories;
133 }
134
135 public ArtifactResolutionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
136 {
137 this.remoteRepositories = remoteRepositories;
138
139 return this;
140 }
141
142
143
144
145
146
147
148 public ArtifactFilter getCollectionFilter()
149 {
150 return collectionFilter;
151 }
152
153 public ArtifactResolutionRequest setCollectionFilter( ArtifactFilter filter )
154 {
155 this.collectionFilter = filter;
156
157 return this;
158 }
159
160
161
162
163
164
165
166
167 public ArtifactFilter getResolutionFilter()
168 {
169 return resolutionFilter;
170 }
171
172 public ArtifactResolutionRequest setResolutionFilter( ArtifactFilter filter )
173 {
174 this.resolutionFilter = filter;
175
176 return this;
177 }
178
179 public List<ResolutionListener> getListeners()
180 {
181 return listeners;
182 }
183
184 public ArtifactResolutionRequest setListeners( List<ResolutionListener> listeners )
185 {
186 this.listeners = listeners;
187
188 return this;
189 }
190
191 public ArtifactResolutionRequest addListener( ResolutionListener listener )
192 {
193 listeners.add( listener );
194
195 return this;
196 }
197
198 public Map<String, Artifact> getManagedVersionMap()
199 {
200 return managedVersionMap;
201 }
202
203 public ArtifactResolutionRequest setManagedVersionMap( Map<String, Artifact> managedVersionMap )
204 {
205 this.managedVersionMap = managedVersionMap;
206
207 return this;
208 }
209
210 public ArtifactResolutionRequest setResolveRoot( boolean resolveRoot )
211 {
212 this.resolveRoot = resolveRoot;
213
214 return this;
215 }
216
217 public boolean isResolveRoot()
218 {
219 return resolveRoot;
220 }
221
222 public ArtifactResolutionRequest setResolveTransitively( boolean resolveDependencies )
223 {
224 this.resolveTransitively = resolveDependencies;
225
226 return this;
227 }
228
229 public boolean isResolveTransitively()
230 {
231 return resolveTransitively;
232 }
233
234 public String toString()
235 {
236 StringBuilder sb = new StringBuilder()
237 .append( "REQUEST: " ).append( "\n" )
238 .append( "artifact: " ).append( artifact ).append( "\n" )
239 .append( artifactDependencies ).append( "\n" )
240 .append( "localRepository: " ).append( localRepository ).append( "\n" )
241 .append( "remoteRepositories: " ).append( remoteRepositories ).append( "\n" );
242
243 return sb.toString();
244 }
245
246 public boolean isOffline()
247 {
248 return offline;
249 }
250
251 public ArtifactResolutionRequest setOffline( boolean offline )
252 {
253 this.offline = offline;
254
255 return this;
256 }
257
258 public boolean isForceUpdate()
259 {
260 return forceUpdate;
261 }
262
263 public ArtifactResolutionRequest setForceUpdate( boolean forceUpdate )
264 {
265 this.forceUpdate = forceUpdate;
266
267 return this;
268 }
269
270 public ArtifactResolutionRequest setServers( List<Server> servers )
271 {
272 this.servers = servers;
273
274 return this;
275 }
276
277 public List<Server> getServers()
278 {
279 if ( servers == null )
280 {
281 servers = new ArrayList<Server>();
282 }
283
284 return servers;
285 }
286
287 public ArtifactResolutionRequest setMirrors( List<Mirror> mirrors )
288 {
289 this.mirrors = mirrors;
290
291 return this;
292 }
293
294 public List<Mirror> getMirrors()
295 {
296 if ( mirrors == null )
297 {
298 mirrors = new ArrayList<Mirror>();
299 }
300
301 return mirrors;
302 }
303
304 public ArtifactResolutionRequest setProxies( List<Proxy> proxies )
305 {
306 this.proxies = proxies;
307
308 return this;
309 }
310
311 public List<Proxy> getProxies()
312 {
313 if ( proxies == null )
314 {
315 proxies = new ArrayList<Proxy>();
316 }
317
318 return proxies;
319 }
320
321
322
323
324
325 public ArtifactResolutionRequest setCache( RepositoryCache cache )
326 {
327 return this;
328 }
329 }