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 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 getManagedVersionMap()
199 {
200 return managedVersionMap;
201 }
202
203 public ArtifactResolutionRequest setManagedVersionMap( Map 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 RepositoryCache getCache()
247 {
248 return null;
249 }
250
251 public ArtifactResolutionRequest setCache( RepositoryCache cache )
252 {
253 return this;
254 }
255
256 public boolean isOffline()
257 {
258 return offline;
259 }
260
261 public ArtifactResolutionRequest setOffline( boolean offline )
262 {
263 this.offline = offline;
264
265 return this;
266 }
267
268 public boolean isForceUpdate()
269 {
270 return forceUpdate;
271 }
272
273 public ArtifactResolutionRequest setForceUpdate( boolean forceUpdate )
274 {
275 this.forceUpdate = forceUpdate;
276
277 return this;
278 }
279
280 public ArtifactResolutionRequest setServers( List<Server> servers )
281 {
282 this.servers = servers;
283
284 return this;
285 }
286
287 public List<Server> getServers()
288 {
289 if ( servers == null )
290 {
291 servers = new ArrayList<Server>();
292 }
293
294 return servers;
295 }
296
297 public ArtifactResolutionRequest setMirrors( List<Mirror> mirrors )
298 {
299 this.mirrors = mirrors;
300
301 return this;
302 }
303
304 public List<Mirror> getMirrors()
305 {
306 if ( mirrors == null )
307 {
308 mirrors = new ArrayList<Mirror>();
309 }
310
311 return mirrors;
312 }
313
314 public ArtifactResolutionRequest setProxies( List<Proxy> proxies )
315 {
316 this.proxies = proxies;
317
318 return this;
319 }
320
321 public List<Proxy> getProxies()
322 {
323 if ( proxies == null )
324 {
325 proxies = new ArrayList<Proxy>();
326 }
327
328 return proxies;
329 }
330
331 }