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