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