View Javadoc

1   package org.apache.maven.settings;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  /**
27   * To handle runtime informations like local repository or profiles.
28   *
29   * @version $Id: RuntimeInfo.java 638306 2008-03-18 10:20:28Z bentmann $
30   */
31  public class RuntimeInfo
32  {
33      private File file;
34  
35      // using Boolean for 3VL (null for not-set, otherwise override with value)
36      private Boolean pluginUpdateForced;
37  
38      // using Boolean for 3VL (null, true-to-all, false-to-all)
39      private Boolean applyToAllPluginUpdates;
40  
41  //    private boolean pluginRegistryActive = true;
42  
43      // using Boolean for 3VL (null for not-set, otherwise override with value)
44  //    private Boolean checkLatest;
45  
46      private Map activeProfileToSourceLevel = new HashMap();
47  
48      private String localRepositorySourceLevel = TrackableBase.USER_LEVEL;
49  
50      private Map pluginGroupIdSourceLevels = new HashMap();
51  
52      private final Settings settings;
53  
54      /**
55       * @param settings
56       */
57      public RuntimeInfo( Settings settings )
58      {
59          this.settings = settings;
60      }
61  
62      /**
63       * @param file
64       */
65      public void setFile( File file )
66      {
67          this.file = file;
68      }
69  
70      /**
71       * @return
72       */
73      public File getFile()
74      {
75          return file;
76      }
77  
78      /**
79       * @param pluginUpdateForced
80       */
81      public void setPluginUpdateOverride( Boolean pluginUpdateForced )
82      {
83          this.pluginUpdateForced = pluginUpdateForced;
84      }
85  
86      /**
87       * @return
88       */
89      public Boolean getPluginUpdateOverride()
90      {
91          return pluginUpdateForced;
92      }
93  
94      /**
95       * @return
96       */
97      public Boolean getApplyToAllPluginUpdates()
98      {
99          return applyToAllPluginUpdates;
100     }
101 
102     /**
103      * @param applyToAll
104      */
105     public void setApplyToAllPluginUpdates( Boolean applyToAll )
106     {
107         this.applyToAllPluginUpdates = applyToAll;
108     }
109 
110     /**
111      * @param activeProfile
112      * @param sourceLevel
113      */
114     public void setActiveProfileSourceLevel( String activeProfile, String sourceLevel )
115     {
116         activeProfileToSourceLevel.put( activeProfile, sourceLevel );
117     }
118 
119     /**
120      * @param activeProfile
121      * @return
122      */
123     public String getSourceLevelForActiveProfile( String activeProfile )
124     {
125         String sourceLevel = (String) activeProfileToSourceLevel.get( activeProfile );
126 
127         if ( sourceLevel != null )
128         {
129             return sourceLevel;
130         }
131         else
132         {
133             return settings.getSourceLevel();
134         }
135     }
136 
137     /**
138      * @param pluginGroupId
139      * @param sourceLevel
140      */
141     public void setPluginGroupIdSourceLevel( String pluginGroupId, String sourceLevel )
142     {
143         pluginGroupIdSourceLevels.put( pluginGroupId, sourceLevel );
144     }
145 
146     /**
147      * @param pluginGroupId
148      * @return
149      */
150     public String getSourceLevelForPluginGroupId( String pluginGroupId )
151     {
152         String sourceLevel = (String) pluginGroupIdSourceLevels.get( pluginGroupId );
153 
154         if ( sourceLevel != null )
155         {
156             return sourceLevel;
157         }
158         else
159         {
160             return settings.getSourceLevel();
161         }
162     }
163 
164     /**
165      * @param localRepoSourceLevel
166      */
167     public void setLocalRepositorySourceLevel( String localRepoSourceLevel )
168     {
169         this.localRepositorySourceLevel = localRepoSourceLevel;
170     }
171 
172     /**
173      * @return
174      */
175     public String getLocalRepositorySourceLevel()
176     {
177         return localRepositorySourceLevel;
178     }
179 }