001: package org.apache.maven.embedder;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.codehaus.plexus.PlexusContainer;
023: import org.codehaus.plexus.classworlds.ClassWorld;
024:
025: import java.io.File;
026: import java.net.URL;
027: import java.util.ArrayList;
028: import java.util.List;
029: import java.util.Properties;
030:
031: /**
032: * Default implementation of Configuration intefrace.
033: *
034: * @author mkleint
035: */
036: public class DefaultConfiguration implements Configuration {
037: private List inactives;
038:
039: private List actives;
040:
041: private File userSettings;
042:
043: private File globalSettings;
044:
045: private ContainerCustomizer customizer;
046:
047: private Properties systemProperties;
048:
049: /** List<URL>. */
050: private List extensions = new ArrayList();
051:
052: private MavenEmbedderLogger logger;
053:
054: private ClassWorld classWorld;
055:
056: private PlexusContainer parentContainer;
057:
058: private File localRepository;
059:
060: /** Creates a new instance of DefaultConfiguration */
061: public DefaultConfiguration() {
062: }
063:
064: public Configuration addActiveProfile(String profile) {
065: getActiveProfiles().add(profile);
066:
067: return this ;
068: }
069:
070: public Configuration addInactiveProfile(String profile) {
071: getInactiveProfiles().add(profile);
072:
073: return this ;
074: }
075:
076: public Configuration addActiveProfiles(List profiles) {
077: getActiveProfiles().addAll(profiles);
078:
079: return this ;
080: }
081:
082: public Configuration addInactiveProfiles(List profiles) {
083: getInactiveProfiles().addAll(profiles);
084:
085: return this ;
086: }
087:
088: public List getActiveProfiles() {
089: if (actives == null) {
090: actives = new ArrayList();
091: }
092: return actives;
093: }
094:
095: public List getInactiveProfiles() {
096: if (inactives == null) {
097: inactives = new ArrayList();
098: }
099: return inactives;
100: }
101:
102: public Configuration setUserSettingsFile(File user) {
103: userSettings = user;
104: return this ;
105: }
106:
107: public Configuration setGlobalSettingsFile(File global) {
108: globalSettings = global;
109: return this ;
110: }
111:
112: public File getUserSettingsFile() {
113: return userSettings;
114: }
115:
116: public File getGlobalSettingsFile() {
117: return globalSettings;
118: }
119:
120: public Configuration setConfigurationCustomizer(
121: ContainerCustomizer customizer) {
122: this .customizer = customizer;
123: return this ;
124: }
125:
126: public ContainerCustomizer getContainerCustomizer() {
127: return customizer;
128: }
129:
130: public Configuration setSystemProperties(Properties properties) {
131: systemProperties = properties;
132: return this ;
133: }
134:
135: public Properties getSystemProperties() {
136: return systemProperties != null ? systemProperties : System
137: .getProperties();
138: }
139:
140: public void addExtension(URL url) {
141: extensions.add(url);
142: }
143:
144: public List getExtensions() {
145: return extensions;
146: }
147:
148: public Configuration setMavenEmbedderLogger(
149: MavenEmbedderLogger logger) {
150: this .logger = logger;
151: return this ;
152: }
153:
154: public MavenEmbedderLogger getMavenEmbedderLogger() {
155: return logger;
156: }
157:
158: public ClassWorld getClassWorld() {
159: return classWorld;
160: }
161:
162: public Configuration setClassWorld(ClassWorld classWorld) {
163: this .classWorld = classWorld;
164: return this ;
165: }
166:
167: public Configuration setClassLoader(ClassLoader loader) {
168: this .classWorld = new ClassWorld("plexus.core", loader);
169:
170: return this ;
171: }
172:
173: public PlexusContainer getParentContainer() {
174: return parentContainer;
175: }
176:
177: public Configuration setParentContainer(
178: PlexusContainer parentContainer) {
179: this .parentContainer = parentContainer;
180: return this ;
181: }
182:
183: // ----------------------------------------------------------------------------
184: // Local Repository
185: // ----------------------------------------------------------------------------
186:
187: public Configuration setLocalRepository(File localRepository) {
188: this .localRepository = localRepository;
189:
190: return this ;
191: }
192:
193: public File getLocalRepository() {
194: return localRepository;
195: }
196: }
|