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   */
19  package org.apache.maven.settings.building;
20  
21  import java.io.File;
22  import java.util.Properties;
23  
24  /**
25   * Collects settings that control building of effective settings.
26   *
27   */
28  public class DefaultSettingsBuildingRequest implements SettingsBuildingRequest {
29  
30      private File globalSettingsFile;
31  
32      private File projectSettingsFile;
33  
34      private File userSettingsFile;
35  
36      private SettingsSource globalSettingsSource;
37  
38      private SettingsSource projectSettingsSource;
39  
40      private SettingsSource userSettingsSource;
41  
42      private Properties systemProperties;
43  
44      private Properties userProperties;
45  
46      @Override
47      public File getGlobalSettingsFile() {
48          return globalSettingsFile;
49      }
50  
51      @Override
52      public DefaultSettingsBuildingRequest setGlobalSettingsFile(File globalSettingsFile) {
53          this.globalSettingsFile = globalSettingsFile;
54  
55          return this;
56      }
57  
58      @Override
59      public SettingsSource getGlobalSettingsSource() {
60          return globalSettingsSource;
61      }
62  
63      @Override
64      public DefaultSettingsBuildingRequest setGlobalSettingsSource(SettingsSource globalSettingsSource) {
65          this.globalSettingsSource = globalSettingsSource;
66  
67          return this;
68      }
69  
70      @Override
71      public File getProjectSettingsFile() {
72          return projectSettingsFile;
73      }
74  
75      @Override
76      public DefaultSettingsBuildingRequest setProjectSettingsFile(File projectSettingsFile) {
77          this.projectSettingsFile = projectSettingsFile;
78  
79          return this;
80      }
81  
82      @Override
83      public SettingsSource getProjectSettingsSource() {
84          return projectSettingsSource;
85      }
86  
87      @Override
88      public DefaultSettingsBuildingRequest setProjectSettingsSource(SettingsSource projectSettingsSource) {
89          this.projectSettingsSource = projectSettingsSource;
90  
91          return this;
92      }
93  
94      @Override
95      public File getUserSettingsFile() {
96          return userSettingsFile;
97      }
98  
99      @Override
100     public DefaultSettingsBuildingRequest setUserSettingsFile(File userSettingsFile) {
101         this.userSettingsFile = userSettingsFile;
102 
103         return this;
104     }
105 
106     @Override
107     public SettingsSource getUserSettingsSource() {
108         return userSettingsSource;
109     }
110 
111     @Override
112     public DefaultSettingsBuildingRequest setUserSettingsSource(SettingsSource userSettingsSource) {
113         this.userSettingsSource = userSettingsSource;
114 
115         return this;
116     }
117 
118     @Override
119     public Properties getSystemProperties() {
120         if (systemProperties == null) {
121             systemProperties = new Properties();
122         }
123 
124         return systemProperties;
125     }
126 
127     @Override
128     public DefaultSettingsBuildingRequest setSystemProperties(Properties systemProperties) {
129         if (systemProperties != null) {
130             this.systemProperties = new Properties();
131             synchronized (systemProperties) { // avoid concurrent modification if someone else sets/removes an unrelated
132                 // system property
133                 this.systemProperties.putAll(systemProperties);
134             }
135         } else {
136             this.systemProperties = null;
137         }
138 
139         return this;
140     }
141 
142     @Override
143     public Properties getUserProperties() {
144         if (userProperties == null) {
145             userProperties = new Properties();
146         }
147 
148         return userProperties;
149     }
150 
151     @Override
152     public DefaultSettingsBuildingRequest setUserProperties(Properties userProperties) {
153         if (userProperties != null) {
154             this.userProperties = new Properties();
155             this.userProperties.putAll(userProperties);
156         } else {
157             this.userProperties = null;
158         }
159 
160         return this;
161     }
162 }