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