1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.apache.maven.settings; |
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | 8 | public class Settings |
18 | |
extends TrackableBase |
19 | |
implements java.io.Serializable |
20 | |
{ |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
private String localRepository; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 8 | private boolean interactiveMode = true; |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | 8 | private boolean usePluginRegistry = false; |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | 8 | private boolean offline = false; |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
private java.util.List<Proxy> proxies; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
private java.util.List<Server> servers; |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
private java.util.List<Mirror> mirrors; |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
private java.util.List<Profile> profiles; |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
private java.util.List<String> activeProfiles; |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
private java.util.List<String> pluginGroups; |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | 8 | private String modelEncoding = "UTF-8"; |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public void addActiveProfile( String string ) |
111 | |
{ |
112 | 0 | if ( !(string instanceof String) ) |
113 | |
{ |
114 | 0 | throw new ClassCastException( "Settings.addActiveProfiles(string) parameter must be instanceof " + String.class.getName() ); |
115 | |
} |
116 | 0 | getActiveProfiles().add( string ); |
117 | 0 | } |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
public void addMirror( Mirror mirror ) |
125 | |
{ |
126 | 0 | if ( !(mirror instanceof Mirror) ) |
127 | |
{ |
128 | 0 | throw new ClassCastException( "Settings.addMirrors(mirror) parameter must be instanceof " + Mirror.class.getName() ); |
129 | |
} |
130 | 0 | getMirrors().add( mirror ); |
131 | 0 | } |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public void addPluginGroup( String string ) |
139 | |
{ |
140 | 3 | if ( !(string instanceof String) ) |
141 | |
{ |
142 | 0 | throw new ClassCastException( "Settings.addPluginGroups(string) parameter must be instanceof " + String.class.getName() ); |
143 | |
} |
144 | 3 | getPluginGroups().add( string ); |
145 | 3 | } |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
public void addProfile( Profile profile ) |
153 | |
{ |
154 | 0 | if ( !(profile instanceof Profile) ) |
155 | |
{ |
156 | 0 | throw new ClassCastException( "Settings.addProfiles(profile) parameter must be instanceof " + Profile.class.getName() ); |
157 | |
} |
158 | 0 | getProfiles().add( profile ); |
159 | 0 | } |
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
public void addProxy( Proxy proxy ) |
167 | |
{ |
168 | 0 | if ( !(proxy instanceof Proxy) ) |
169 | |
{ |
170 | 0 | throw new ClassCastException( "Settings.addProxies(proxy) parameter must be instanceof " + Proxy.class.getName() ); |
171 | |
} |
172 | 0 | getProxies().add( proxy ); |
173 | 0 | } |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
public void addServer( Server server ) |
181 | |
{ |
182 | 0 | if ( !(server instanceof Server) ) |
183 | |
{ |
184 | 0 | throw new ClassCastException( "Settings.addServers(server) parameter must be instanceof " + Server.class.getName() ); |
185 | |
} |
186 | 0 | getServers().add( server ); |
187 | 0 | } |
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
public java.util.List<String> getActiveProfiles() |
195 | |
{ |
196 | 11 | if ( this.activeProfiles == null ) |
197 | |
{ |
198 | 8 | this.activeProfiles = new java.util.ArrayList<String>(); |
199 | |
} |
200 | |
|
201 | 11 | return this.activeProfiles; |
202 | |
} |
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
public String getLocalRepository() |
210 | |
{ |
211 | 11 | return this.localRepository; |
212 | |
} |
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
|
219 | |
public java.util.List<Mirror> getMirrors() |
220 | |
{ |
221 | 8 | if ( this.mirrors == null ) |
222 | |
{ |
223 | 8 | this.mirrors = new java.util.ArrayList<Mirror>(); |
224 | |
} |
225 | |
|
226 | 8 | return this.mirrors; |
227 | |
} |
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
public String getModelEncoding() |
236 | |
{ |
237 | 0 | return modelEncoding; |
238 | |
} |
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
public java.util.List<String> getPluginGroups() |
246 | |
{ |
247 | 12 | if ( this.pluginGroups == null ) |
248 | |
{ |
249 | 8 | this.pluginGroups = new java.util.ArrayList<String>(); |
250 | |
} |
251 | |
|
252 | 12 | return this.pluginGroups; |
253 | |
} |
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
public java.util.List<Profile> getProfiles() |
261 | |
{ |
262 | 11 | if ( this.profiles == null ) |
263 | |
{ |
264 | 8 | this.profiles = new java.util.ArrayList<Profile>(); |
265 | |
} |
266 | |
|
267 | 11 | return this.profiles; |
268 | |
} |
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
public java.util.List<Proxy> getProxies() |
276 | |
{ |
277 | 11 | if ( this.proxies == null ) |
278 | |
{ |
279 | 5 | this.proxies = new java.util.ArrayList<Proxy>(); |
280 | |
} |
281 | |
|
282 | 11 | return this.proxies; |
283 | |
} |
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
public java.util.List<Server> getServers() |
291 | |
{ |
292 | 8 | if ( this.servers == null ) |
293 | |
{ |
294 | 8 | this.servers = new java.util.ArrayList<Server>(); |
295 | |
} |
296 | |
|
297 | 8 | return this.servers; |
298 | |
} |
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
public boolean isInteractiveMode() |
307 | |
{ |
308 | 0 | return this.interactiveMode; |
309 | |
} |
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
public boolean isOffline() |
318 | |
{ |
319 | 0 | return this.offline; |
320 | |
} |
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
public boolean isUsePluginRegistry() |
329 | |
{ |
330 | 0 | return this.usePluginRegistry; |
331 | |
} |
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
public void removeActiveProfile( String string ) |
339 | |
{ |
340 | 0 | if ( !(string instanceof String) ) |
341 | |
{ |
342 | 0 | throw new ClassCastException( "Settings.removeActiveProfiles(string) parameter must be instanceof " + String.class.getName() ); |
343 | |
} |
344 | 0 | getActiveProfiles().remove( string ); |
345 | 0 | } |
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
public void removeMirror( Mirror mirror ) |
353 | |
{ |
354 | 0 | if ( !(mirror instanceof Mirror) ) |
355 | |
{ |
356 | 0 | throw new ClassCastException( "Settings.removeMirrors(mirror) parameter must be instanceof " + Mirror.class.getName() ); |
357 | |
} |
358 | 0 | getMirrors().remove( mirror ); |
359 | 0 | } |
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
public void removePluginGroup( String string ) |
367 | |
{ |
368 | 0 | if ( !(string instanceof String) ) |
369 | |
{ |
370 | 0 | throw new ClassCastException( "Settings.removePluginGroups(string) parameter must be instanceof " + String.class.getName() ); |
371 | |
} |
372 | 0 | getPluginGroups().remove( string ); |
373 | 0 | } |
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
public void removeProfile( Profile profile ) |
381 | |
{ |
382 | 0 | if ( !(profile instanceof Profile) ) |
383 | |
{ |
384 | 0 | throw new ClassCastException( "Settings.removeProfiles(profile) parameter must be instanceof " + Profile.class.getName() ); |
385 | |
} |
386 | 0 | getProfiles().remove( profile ); |
387 | 0 | } |
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
public void removeProxy( Proxy proxy ) |
395 | |
{ |
396 | 0 | if ( !(proxy instanceof Proxy) ) |
397 | |
{ |
398 | 0 | throw new ClassCastException( "Settings.removeProxies(proxy) parameter must be instanceof " + Proxy.class.getName() ); |
399 | |
} |
400 | 0 | getProxies().remove( proxy ); |
401 | 0 | } |
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
|
408 | |
public void removeServer( Server server ) |
409 | |
{ |
410 | 0 | if ( !(server instanceof Server) ) |
411 | |
{ |
412 | 0 | throw new ClassCastException( "Settings.removeServers(server) parameter must be instanceof " + Server.class.getName() ); |
413 | |
} |
414 | 0 | getServers().remove( server ); |
415 | 0 | } |
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
public void setActiveProfiles( java.util.List<String> activeProfiles ) |
425 | |
{ |
426 | 0 | this.activeProfiles = activeProfiles; |
427 | 0 | } |
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
public void setInteractiveMode( boolean interactiveMode ) |
436 | |
{ |
437 | 0 | this.interactiveMode = interactiveMode; |
438 | 0 | } |
439 | |
|
440 | |
|
441 | |
|
442 | |
|
443 | |
|
444 | |
|
445 | |
public void setLocalRepository( String localRepository ) |
446 | |
{ |
447 | 7 | this.localRepository = localRepository; |
448 | 7 | } |
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | |
public void setMirrors( java.util.List<Mirror> mirrors ) |
456 | |
{ |
457 | 0 | this.mirrors = mirrors; |
458 | 0 | } |
459 | |
|
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
public void setModelEncoding( String modelEncoding ) |
466 | |
{ |
467 | 0 | this.modelEncoding = modelEncoding; |
468 | 0 | } |
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
public void setOffline( boolean offline ) |
477 | |
{ |
478 | 0 | this.offline = offline; |
479 | 0 | } |
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
public void setPluginGroups( java.util.List<String> pluginGroups ) |
488 | |
{ |
489 | 0 | this.pluginGroups = pluginGroups; |
490 | 0 | } |
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
|
498 | |
public void setProfiles( java.util.List<Profile> profiles ) |
499 | |
{ |
500 | 0 | this.profiles = profiles; |
501 | 0 | } |
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
public void setProxies( java.util.List<Proxy> proxies ) |
518 | |
{ |
519 | 3 | this.proxies = proxies; |
520 | 3 | } |
521 | |
|
522 | |
|
523 | |
|
524 | |
|
525 | |
|
526 | |
|
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
public void setServers( java.util.List<Server> servers ) |
532 | |
{ |
533 | 0 | this.servers = servers; |
534 | 0 | } |
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
|
541 | |
|
542 | |
public void setUsePluginRegistry( boolean usePluginRegistry ) |
543 | |
{ |
544 | 0 | this.usePluginRegistry = usePluginRegistry; |
545 | 0 | } |
546 | |
|
547 | |
|
548 | |
|
549 | |
public Boolean getInteractiveMode() |
550 | |
{ |
551 | 0 | return Boolean.valueOf( isInteractiveMode() ); |
552 | |
} |
553 | |
|
554 | |
private Proxy activeProxy; |
555 | |
|
556 | |
|
557 | |
|
558 | |
|
559 | |
public void flushActiveProxy() |
560 | |
{ |
561 | 0 | this.activeProxy = null; |
562 | 0 | } |
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
public synchronized Proxy getActiveProxy() |
568 | |
{ |
569 | 3 | if(activeProxy == null) |
570 | |
{ |
571 | 3 | java.util.List proxies = getProxies(); |
572 | 3 | if ( proxies != null && !proxies.isEmpty() ) |
573 | |
{ |
574 | 2 | for ( java.util.Iterator it = proxies.iterator(); it.hasNext(); ) |
575 | |
{ |
576 | 2 | Proxy proxy = (Proxy) it.next(); |
577 | 2 | if ( proxy.isActive() ) |
578 | |
{ |
579 | 1 | activeProxy = proxy; |
580 | 1 | break; |
581 | |
} |
582 | 1 | } |
583 | |
} |
584 | |
} |
585 | |
|
586 | 3 | return activeProxy; |
587 | |
} |
588 | |
|
589 | |
public Server getServer( String serverId ) |
590 | |
{ |
591 | 0 | Server match = null; |
592 | |
|
593 | 0 | java.util.List servers = getServers(); |
594 | 0 | if ( servers != null && serverId != null ) |
595 | |
{ |
596 | 0 | for ( java.util.Iterator it = servers.iterator(); it.hasNext(); ) |
597 | |
{ |
598 | 0 | Server server = (Server) it.next(); |
599 | 0 | if ( serverId.equals( server.getId() ) ) |
600 | |
{ |
601 | 0 | match = server; |
602 | 0 | break; |
603 | |
} |
604 | 0 | } |
605 | |
} |
606 | |
|
607 | 0 | return match; |
608 | |
} |
609 | |
|
610 | |
public Mirror getMirrorOf( String repositoryId ) |
611 | |
{ |
612 | 0 | Mirror match = null; |
613 | |
|
614 | 0 | java.util.List mirrors = getMirrors(); |
615 | 0 | if ( mirrors != null && repositoryId != null ) |
616 | |
{ |
617 | 0 | for ( java.util.Iterator it = mirrors.iterator(); it.hasNext(); ) |
618 | |
{ |
619 | 0 | Mirror mirror = (Mirror) it.next(); |
620 | 0 | if ( repositoryId.equals( mirror.getMirrorOf() ) ) |
621 | |
{ |
622 | 0 | match = mirror; |
623 | 0 | break; |
624 | |
} |
625 | 0 | } |
626 | |
} |
627 | |
|
628 | 0 | return match; |
629 | |
} |
630 | |
|
631 | |
private java.util.Map profileMap; |
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
public void flushProfileMap() |
637 | |
{ |
638 | 0 | this.profileMap = null; |
639 | 0 | } |
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
|
645 | |
public java.util.Map getProfilesAsMap() |
646 | |
{ |
647 | 0 | if ( profileMap == null ) |
648 | |
{ |
649 | 0 | profileMap = new java.util.LinkedHashMap(); |
650 | |
|
651 | 0 | if ( getProfiles() != null ) |
652 | |
{ |
653 | 0 | for ( java.util.Iterator it = getProfiles().iterator(); it.hasNext(); ) |
654 | |
{ |
655 | 0 | Profile profile = (Profile) it.next(); |
656 | |
|
657 | 0 | profileMap.put( profile.getId(), profile ); |
658 | 0 | } |
659 | |
} |
660 | |
} |
661 | |
|
662 | 0 | return profileMap; |
663 | |
} |
664 | |
|
665 | |
private RuntimeInfo runtimeInfo; |
666 | |
|
667 | |
public void setRuntimeInfo( RuntimeInfo runtimeInfo ) |
668 | |
{ |
669 | 5 | this.runtimeInfo = runtimeInfo; |
670 | 5 | } |
671 | |
|
672 | |
public RuntimeInfo getRuntimeInfo() |
673 | |
{ |
674 | 5 | return runtimeInfo; |
675 | |
} |
676 | |
|
677 | |
|
678 | |
} |