View Javadoc
1   /*
2    Licensed to the Apache Software Foundation (ASF) under one
3    or more contributor license agreements.  See the NOTICE file
4    distributed with this work for additional information
5    regarding copyright ownership.  The ASF licenses this file
6    to you under the Apache License, Version 2.0 (the
7    "License"); you may not use this file except in compliance
8    with the License.  You may obtain a copy of the License at
9    
10       http://www.apache.org/licenses/LICENSE-2.0
11   
12   Unless required by applicable law or agreed to in writing,
13   software distributed under the License is distributed on an
14   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   KIND, either express or implied.  See the License for the
16   specific language governing permissions and limitations
17   under the License.
18   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.4.0,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.settings;
25  
26  /**
27   * 
28   *         Root element of the user configuration file.
29   *       
30   * 
31   * @version $Revision$ $Date$
32   */
33  @SuppressWarnings( "all" )
34  public class Settings
35      extends TrackableBase
36      implements java.io.Serializable, java.lang.Cloneable
37  {
38  
39        //--------------------------/
40       //- Class/Member Variables -/
41      //--------------------------/
42  
43      /**
44       * 
45       *             
46       *             The local repository.<br><b>Default value
47       * is:</b> <code>${user.home}/.m2/repository</code>
48       *             
49       *           
50       */
51      private String localRepository;
52  
53      /**
54       * 
55       *             
56       *             Whether Maven should attempt to interact with
57       * the user for input.
58       *             
59       *           
60       */
61      private boolean interactiveMode = true;
62  
63      /**
64       * 
65       *             
66       *             Whether Maven should use the
67       * <code>plugin-registry.xml</code> file to manage plugin
68       * versions.
69       *             
70       *           
71       */
72      private boolean usePluginRegistry = false;
73  
74      /**
75       * 
76       *             
77       *             Indicate whether maven should operate in offline
78       * mode full-time.
79       *             
80       *           
81       */
82      private boolean offline = false;
83  
84      /**
85       * Field proxies.
86       */
87      private java.util.List<Proxy> proxies;
88  
89      /**
90       * Field servers.
91       */
92      private java.util.List<Server> servers;
93  
94      /**
95       * Field mirrors.
96       */
97      private java.util.List<Mirror> mirrors;
98  
99      /**
100      * Field profiles.
101      */
102     private java.util.List<Profile> profiles;
103 
104     /**
105      * Field activeProfiles.
106      */
107     private java.util.List<String> activeProfiles;
108 
109     /**
110      * Field pluginGroups.
111      */
112     private java.util.List<String> pluginGroups;
113 
114     /**
115      * Field modelEncoding.
116      */
117     private String modelEncoding = "UTF-8";
118 
119 
120       //-----------/
121      //- Methods -/
122     //-----------/
123 
124     /**
125      * Method addActiveProfile.
126      * 
127      * @param string a string object.
128      */
129     public void addActiveProfile( String string )
130     {
131         getActiveProfiles().add( string );
132     } //-- void addActiveProfile( String )
133 
134     /**
135      * Method addMirror.
136      * 
137      * @param mirror a mirror object.
138      */
139     public void addMirror( Mirror mirror )
140     {
141         getMirrors().add( mirror );
142     } //-- void addMirror( Mirror )
143 
144     /**
145      * Method addPluginGroup.
146      * 
147      * @param string a string object.
148      */
149     public void addPluginGroup( String string )
150     {
151         getPluginGroups().add( string );
152     } //-- void addPluginGroup( String )
153 
154     /**
155      * Method addProfile.
156      * 
157      * @param profile a profile object.
158      */
159     public void addProfile( Profile profile )
160     {
161         getProfiles().add( profile );
162     } //-- void addProfile( Profile )
163 
164     /**
165      * Method addProxy.
166      * 
167      * @param proxy a proxy object.
168      */
169     public void addProxy( Proxy proxy )
170     {
171         getProxies().add( proxy );
172     } //-- void addProxy( Proxy )
173 
174     /**
175      * Method addServer.
176      * 
177      * @param server a server object.
178      */
179     public void addServer( Server server )
180     {
181         getServers().add( server );
182     } //-- void addServer( Server )
183 
184     /**
185      * Method clone.
186      * 
187      * @return Settings
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     } //-- Settings clone()
251 
252     /**
253      * Method getActiveProfiles.
254      * 
255      * @return List
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     } //-- java.util.List<String> getActiveProfiles()
266 
267     /**
268      * Get the local repository.<br><b>Default value is:</b>
269      * <code>${user.home}/.m2/repository</code>
270      * 
271      * @return String
272      */
273     public String getLocalRepository()
274     {
275         return this.localRepository;
276     } //-- String getLocalRepository()
277 
278     /**
279      * Method getMirrors.
280      * 
281      * @return List
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     } //-- java.util.List<Mirror> getMirrors()
292 
293     /**
294      * Get the modelEncoding field.
295      * 
296      * @return String
297      */
298     public String getModelEncoding()
299     {
300         return this.modelEncoding;
301     } //-- String getModelEncoding()
302 
303     /**
304      * Method getPluginGroups.
305      * 
306      * @return List
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     } //-- java.util.List<String> getPluginGroups()
317 
318     /**
319      * Method getProfiles.
320      * 
321      * @return List
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     } //-- java.util.List<Profile> getProfiles()
332 
333     /**
334      * Method getProxies.
335      * 
336      * @return List
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     } //-- java.util.List<Proxy> getProxies()
347 
348     /**
349      * Method getServers.
350      * 
351      * @return List
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     } //-- java.util.List<Server> getServers()
362 
363     /**
364      * Get whether Maven should attempt to interact with the user
365      * for input.
366      * 
367      * @return boolean
368      */
369     public boolean isInteractiveMode()
370     {
371         return this.interactiveMode;
372     } //-- boolean isInteractiveMode()
373 
374     /**
375      * Get indicate whether maven should operate in offline mode
376      * full-time.
377      * 
378      * @return boolean
379      */
380     public boolean isOffline()
381     {
382         return this.offline;
383     } //-- boolean isOffline()
384 
385     /**
386      * Get whether Maven should use the
387      * <code>plugin-registry.xml</code> file to manage plugin
388      * versions.
389      * 
390      * @return boolean
391      */
392     public boolean isUsePluginRegistry()
393     {
394         return this.usePluginRegistry;
395     } //-- boolean isUsePluginRegistry()
396 
397     /**
398      * Method removeActiveProfile.
399      * 
400      * @param string a string object.
401      */
402     public void removeActiveProfile( String string )
403     {
404         getActiveProfiles().remove( string );
405     } //-- void removeActiveProfile( String )
406 
407     /**
408      * Method removeMirror.
409      * 
410      * @param mirror a mirror object.
411      */
412     public void removeMirror( Mirror mirror )
413     {
414         getMirrors().remove( mirror );
415     } //-- void removeMirror( Mirror )
416 
417     /**
418      * Method removePluginGroup.
419      * 
420      * @param string a string object.
421      */
422     public void removePluginGroup( String string )
423     {
424         getPluginGroups().remove( string );
425     } //-- void removePluginGroup( String )
426 
427     /**
428      * Method removeProfile.
429      * 
430      * @param profile a profile object.
431      */
432     public void removeProfile( Profile profile )
433     {
434         getProfiles().remove( profile );
435     } //-- void removeProfile( Profile )
436 
437     /**
438      * Method removeProxy.
439      * 
440      * @param proxy a proxy object.
441      */
442     public void removeProxy( Proxy proxy )
443     {
444         getProxies().remove( proxy );
445     } //-- void removeProxy( Proxy )
446 
447     /**
448      * Method removeServer.
449      * 
450      * @param server a server object.
451      */
452     public void removeServer( Server server )
453     {
454         getServers().remove( server );
455     } //-- void removeServer( Server )
456 
457     /**
458      * Set list of manually-activated build profiles, specified in
459      * the order in which
460      *             they should be applied.
461      * 
462      * @param activeProfiles a activeProfiles object.
463      */
464     public void setActiveProfiles( java.util.List<String> activeProfiles )
465     {
466         this.activeProfiles = activeProfiles;
467     } //-- void setActiveProfiles( java.util.List )
468 
469     /**
470      * Set whether Maven should attempt to interact with the user
471      * for input.
472      * 
473      * @param interactiveMode a interactiveMode object.
474      */
475     public void setInteractiveMode( boolean interactiveMode )
476     {
477         this.interactiveMode = interactiveMode;
478     } //-- void setInteractiveMode( boolean )
479 
480     /**
481      * Set the local repository.<br><b>Default value is:</b>
482      * <code>${user.home}/.m2/repository</code>
483      * 
484      * @param localRepository a localRepository object.
485      */
486     public void setLocalRepository( String localRepository )
487     {
488         this.localRepository = localRepository;
489     } //-- void setLocalRepository( String )
490 
491     /**
492      * Set configuration of download mirrors for repositories.
493      * 
494      * @param mirrors a mirrors object.
495      */
496     public void setMirrors( java.util.List<Mirror> mirrors )
497     {
498         this.mirrors = mirrors;
499     } //-- void setMirrors( java.util.List )
500 
501     /**
502      * Set the modelEncoding field.
503      * 
504      * @param modelEncoding a modelEncoding object.
505      */
506     public void setModelEncoding( String modelEncoding )
507     {
508         this.modelEncoding = modelEncoding;
509     } //-- void setModelEncoding( String )
510 
511     /**
512      * Set indicate whether maven should operate in offline mode
513      * full-time.
514      * 
515      * @param offline a offline object.
516      */
517     public void setOffline( boolean offline )
518     {
519         this.offline = offline;
520     } //-- void setOffline( boolean )
521 
522     /**
523      * Set list of groupIds to search for a plugin when that plugin
524      *             groupId is not explicitly provided.
525      * 
526      * @param pluginGroups a pluginGroups object.
527      */
528     public void setPluginGroups( java.util.List<String> pluginGroups )
529     {
530         this.pluginGroups = pluginGroups;
531     } //-- void setPluginGroups( java.util.List )
532 
533     /**
534      * Set configuration of build profiles for adjusting the build
535      *             according to environmental parameters.
536      * 
537      * @param profiles a profiles object.
538      */
539     public void setProfiles( java.util.List<Profile> profiles )
540     {
541         this.profiles = profiles;
542     } //-- void setProfiles( java.util.List )
543 
544     /**
545      * Set configuration for different proxy profiles. Multiple
546      * proxy profiles
547      *             might come in handy for anyone working from a
548      * notebook or other
549      *             mobile platform, to enable easy switching of
550      * entire proxy
551      *             configurations by simply specifying the profile
552      * id, again either from
553      *             the command line or from the defaults section
554      * below.
555      * 
556      * @param proxies a proxies object.
557      */
558     public void setProxies( java.util.List<Proxy> proxies )
559     {
560         this.proxies = proxies;
561     } //-- void setProxies( java.util.List )
562 
563     /**
564      * Set configuration of server-specific settings, mainly
565      * authentication
566      *             method. This allows configuration of
567      * authentication on a per-server
568      *             basis.
569      * 
570      * @param servers a servers object.
571      */
572     public void setServers( java.util.List<Server> servers )
573     {
574         this.servers = servers;
575     } //-- void setServers( java.util.List )
576 
577     /**
578      * Set whether Maven should use the
579      * <code>plugin-registry.xml</code> file to manage plugin
580      * versions.
581      * 
582      * @param usePluginRegistry a usePluginRegistry object.
583      */
584     public void setUsePluginRegistry( boolean usePluginRegistry )
585     {
586         this.usePluginRegistry = usePluginRegistry;
587     } //-- void setUsePluginRegistry( boolean )
588 
589     
590             
591     public Boolean getInteractiveMode()
592     {
593         return Boolean.valueOf( isInteractiveMode() );
594     }
595 
596     private Proxy activeProxy;
597 
598     /**
599      * Reset the <code>activeProxy</code> field to <code>null</code>
600      */
601     public void flushActiveProxy()
602     {
603         this.activeProxy = null;
604     }
605 
606     /**
607      * @return the first active proxy
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      * Reset the <code>profileMap</code> field to <code>null</code>
675      */
676     public void flushProfileMap()
677     {
678         this.profileMap = null;
679     }
680 
681     /**
682      * @return a Map of profiles field with <code>Profile#getId()</code> as key
683      * @see org.apache.maven.settings.Profile#getId()
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 }