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