001: package org.apache.maven.execution;
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.apache.maven.artifact.repository.ArtifactRepository;
023: import org.apache.maven.monitor.event.EventMonitor;
024: import org.apache.maven.profiles.ProfileManager;
025: import org.apache.maven.settings.Settings;
026: import org.apache.maven.wagon.events.TransferListener;
027:
028: import java.io.File;
029: import java.util.ArrayList;
030: import java.util.Date;
031: import java.util.List;
032: import java.util.Properties;
033:
034: /**
035: * @author Jason van Zyl
036: * @version $Id: DefaultMavenExecutionRequest.java 573718 2007-09-07 21:29:08Z jvanzyl $
037: */
038: public class DefaultMavenExecutionRequest implements
039: MavenExecutionRequest {
040: private ArtifactRepository localRepository;
041:
042: private File localRepositoryPath;
043:
044: private boolean offline = false;
045:
046: private boolean interactiveMode = true;
047:
048: private List proxies;
049:
050: private List servers;
051:
052: private List mirrors;
053:
054: private List profiles;
055:
056: private List pluginGroups;
057:
058: private boolean usePluginUpdateOverride;
059:
060: private boolean isProjectPresent = true;
061:
062: // ----------------------------------------------------------------------------
063: // We need to allow per execution user and global settings as the embedder
064: // might be running in a mode where its executing many threads with totally
065: // different settings.
066: // ----------------------------------------------------------------------------
067:
068: private File userSettingsFile;
069:
070: private File globalSettingsFile;
071:
072: // ----------------------------------------------------------------------------
073: // Request
074: // ----------------------------------------------------------------------------
075:
076: private File basedir;
077:
078: private List goals;
079:
080: private boolean useReactor = false;
081:
082: private boolean recursive = true;
083:
084: private String pomFile;
085:
086: private String reactorFailureBehavior = REACTOR_FAIL_FAST;
087:
088: private Properties properties;
089:
090: private Date startTime;
091:
092: private boolean showErrors = false;
093:
094: private List eventMonitors;
095:
096: private List activeProfiles;
097:
098: private List inactiveProfiles;
099:
100: private TransferListener transferListener;
101:
102: private int loggingLevel = LOGGING_LEVEL_INFO;
103:
104: private String globalChecksumPolicy = CHECKSUM_POLICY_WARN;
105:
106: private boolean updateSnapshots = false;
107:
108: private ProfileManager profileManager;
109:
110: /**
111: * Suppress SNAPSHOT updates.
112: * @issue MNG-2681
113: */
114: private boolean noSnapshotUpdates;
115:
116: public String getBaseDirectory() {
117: if (basedir == null) {
118: return null;
119: }
120:
121: return basedir.getAbsolutePath();
122: }
123:
124: public ArtifactRepository getLocalRepository() {
125: return localRepository;
126: }
127:
128: public File getLocalRepositoryPath() {
129: return localRepositoryPath;
130: }
131:
132: public List getGoals() {
133: return goals;
134: }
135:
136: public Properties getProperties() {
137: return properties;
138: }
139:
140: public String getPomFile() {
141: return pomFile;
142: }
143:
144: public String getReactorFailureBehavior() {
145: return reactorFailureBehavior;
146: }
147:
148: public Date getStartTime() {
149: return startTime;
150: }
151:
152: public boolean isShowErrors() {
153: return showErrors;
154: }
155:
156: public boolean isInteractiveMode() {
157: return interactiveMode;
158: }
159:
160: public List getEventMonitors() {
161: return eventMonitors;
162: }
163:
164: public List getActiveProfiles() {
165: if (activeProfiles == null) {
166: activeProfiles = new ArrayList();
167: }
168: return activeProfiles;
169: }
170:
171: public List getInactiveProfiles() {
172: if (inactiveProfiles == null) {
173: inactiveProfiles = new ArrayList();
174: }
175: return inactiveProfiles;
176: }
177:
178: public TransferListener getTransferListener() {
179: return transferListener;
180: }
181:
182: public int getLoggingLevel() {
183: return loggingLevel;
184: }
185:
186: public boolean isOffline() {
187: return offline;
188: }
189:
190: public boolean isUpdateSnapshots() {
191: return updateSnapshots;
192: }
193:
194: public boolean isNoSnapshotUpdates() {
195: return noSnapshotUpdates;
196: }
197:
198: public String getGlobalChecksumPolicy() {
199: return globalChecksumPolicy;
200: }
201:
202: public boolean isRecursive() {
203: return recursive;
204: }
205:
206: // ----------------------------------------------------------------------
207: //
208: // ----------------------------------------------------------------------
209:
210: public MavenExecutionRequest setBaseDirectory(File basedir) {
211: this .basedir = basedir;
212:
213: return this ;
214: }
215:
216: public MavenExecutionRequest setStartTime(Date startTime) {
217: this .startTime = startTime;
218:
219: return this ;
220: }
221:
222: public MavenExecutionRequest setShowErrors(boolean showErrors) {
223: this .showErrors = showErrors;
224:
225: return this ;
226: }
227:
228: public MavenExecutionRequest setGoals(List goals) {
229: this .goals = goals;
230:
231: return this ;
232: }
233:
234: public MavenExecutionRequest setLocalRepository(
235: ArtifactRepository localRepository) {
236: this .localRepository = localRepository;
237:
238: return this ;
239: }
240:
241: public MavenExecutionRequest setLocalRepositoryPath(
242: File localRepository) {
243: this .localRepositoryPath = localRepository;
244:
245: return this ;
246: }
247:
248: public MavenExecutionRequest setLocalRepositoryPath(
249: String localRepository) {
250: this .localRepositoryPath = new File(localRepository);
251:
252: return this ;
253: }
254:
255: public MavenExecutionRequest setProperties(Properties properties) {
256: if (this .properties == null) {
257: this .properties = properties;
258: } else {
259: this .properties.putAll(properties);
260: }
261:
262: return this ;
263: }
264:
265: public MavenExecutionRequest setProperty(String key, String value) {
266: if (properties == null) {
267: properties = new Properties();
268: }
269:
270: properties.setProperty(key, value);
271:
272: return this ;
273: }
274:
275: public MavenExecutionRequest setReactorFailureBehavior(
276: String failureBehavior) {
277: this .reactorFailureBehavior = failureBehavior;
278:
279: return this ;
280: }
281:
282: public MavenExecutionRequest addActiveProfile(String profile) {
283: getActiveProfiles().add(profile);
284:
285: return this ;
286: }
287:
288: public MavenExecutionRequest addInactiveProfile(String profile) {
289: getInactiveProfiles().add(profile);
290:
291: return this ;
292: }
293:
294: public MavenExecutionRequest addActiveProfiles(List profiles) {
295: getActiveProfiles().addAll(profiles);
296:
297: return this ;
298: }
299:
300: public MavenExecutionRequest addInactiveProfiles(List profiles) {
301: getInactiveProfiles().addAll(profiles);
302:
303: return this ;
304: }
305:
306: public MavenExecutionRequest addEventMonitor(EventMonitor monitor) {
307: if (eventMonitors == null) {
308: eventMonitors = new ArrayList();
309: }
310:
311: eventMonitors.add(monitor);
312:
313: return this ;
314: }
315:
316: public MavenExecutionRequest setUseReactor(boolean reactorActive) {
317: this .useReactor = reactorActive;
318:
319: return this ;
320: }
321:
322: public boolean useReactor() {
323: return useReactor;
324: }
325:
326: public MavenExecutionRequest setPomFile(String pomFilename) {
327: this .pomFile = pomFilename;
328:
329: return this ;
330: }
331:
332: public MavenExecutionRequest setInteractiveMode(boolean interactive) {
333: this .interactiveMode = interactive;
334:
335: return this ;
336: }
337:
338: public MavenExecutionRequest setTransferListener(
339: TransferListener transferListener) {
340: this .transferListener = transferListener;
341:
342: return this ;
343: }
344:
345: public MavenExecutionRequest setLoggingLevel(int loggingLevel) {
346: this .loggingLevel = loggingLevel;
347:
348: return this ;
349: }
350:
351: public MavenExecutionRequest setOffline(boolean offline) {
352: this .offline = offline;
353:
354: return this ;
355: }
356:
357: public MavenExecutionRequest setUpdateSnapshots(
358: boolean updateSnapshots) {
359: this .updateSnapshots = updateSnapshots;
360:
361: return this ;
362: }
363:
364: public MavenExecutionRequest setNoSnapshotUpdates(
365: boolean noSnapshotUpdates) {
366: this .noSnapshotUpdates = noSnapshotUpdates;
367:
368: return this ;
369: }
370:
371: public MavenExecutionRequest setGlobalChecksumPolicy(
372: String globalChecksumPolicy) {
373: this .globalChecksumPolicy = globalChecksumPolicy;
374:
375: return this ;
376: }
377:
378: // ----------------------------------------------------------------------------
379: // Settings equivalents
380: // ----------------------------------------------------------------------------
381:
382: public List getProxies() {
383: return proxies;
384: }
385:
386: public MavenExecutionRequest setProxies(List proxies) {
387: this .proxies = proxies;
388:
389: return this ;
390: }
391:
392: public List getServers() {
393: return servers;
394: }
395:
396: public MavenExecutionRequest setServers(List servers) {
397: this .servers = servers;
398:
399: return this ;
400: }
401:
402: public List getMirrors() {
403: return mirrors;
404: }
405:
406: public MavenExecutionRequest setMirrors(List mirrors) {
407: this .mirrors = mirrors;
408:
409: return this ;
410: }
411:
412: public List getProfiles() {
413: return profiles;
414: }
415:
416: public MavenExecutionRequest setProfiles(List profiles) {
417: this .profiles = profiles;
418:
419: return this ;
420: }
421:
422: public List getPluginGroups() {
423: return pluginGroups;
424: }
425:
426: public MavenExecutionRequest setPluginGroups(List pluginGroups) {
427: this .pluginGroups = pluginGroups;
428:
429: return this ;
430: }
431:
432: public boolean isUsePluginUpdateOverride() {
433: return usePluginUpdateOverride;
434: }
435:
436: public MavenExecutionRequest setUsePluginUpdateOverride(
437: boolean usePluginUpdateOverride) {
438: this .usePluginUpdateOverride = usePluginUpdateOverride;
439:
440: return this ;
441: }
442:
443: public MavenExecutionRequest setRecursive(boolean recursive) {
444: this .recursive = recursive;
445:
446: return this ;
447: }
448:
449: private Settings settings;
450:
451: public MavenExecutionRequest setSettings(Settings settings) {
452: this .settings = settings;
453:
454: return this ;
455: }
456:
457: public Settings getSettings() {
458: return settings;
459: }
460:
461: public ProfileManager getProfileManager() {
462: return profileManager;
463: }
464:
465: public MavenExecutionRequest setProfileManager(
466: ProfileManager profileManager) {
467: this .profileManager = profileManager;
468:
469: return this ;
470: }
471:
472: public boolean isProjectPresent() {
473: return isProjectPresent;
474: }
475:
476: public MavenExecutionRequest setProjectPresent(
477: boolean projectPresent) {
478: isProjectPresent = projectPresent;
479:
480: return this ;
481: }
482:
483: // Settings files
484:
485: public File getUserSettingsFile() {
486: return userSettingsFile;
487: }
488:
489: public MavenExecutionRequest setUserSettingsFile(
490: File userSettingsFile) {
491: this .userSettingsFile = userSettingsFile;
492:
493: return this ;
494: }
495:
496: public File getGlobalSettingsFile() {
497: return globalSettingsFile;
498: }
499:
500: public MavenExecutionRequest setGlobalSettingsFile(
501: File globalSettingsFile) {
502: this.globalSettingsFile = globalSettingsFile;
503:
504: return this;
505: }
506: }
|