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.execution;
20  
21  import java.io.File;
22  import java.util.Date;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.Properties;
26  import org.apache.maven.artifact.repository.ArtifactRepository;
27  import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
28  import org.apache.maven.eventspy.internal.EventSpyDispatcher;
29  import org.apache.maven.model.Profile;
30  import org.apache.maven.project.ProjectBuildingRequest;
31  import org.apache.maven.settings.Mirror;
32  import org.apache.maven.settings.Proxy;
33  import org.apache.maven.settings.Server;
34  import org.apache.maven.toolchain.model.ToolchainModel;
35  import org.codehaus.plexus.logging.Logger;
36  import org.eclipse.aether.RepositoryCache;
37  import org.eclipse.aether.repository.WorkspaceReader;
38  import org.eclipse.aether.transfer.TransferListener;
39  
40  /**
41   * @author Jason van Zyl
42   */
43  public interface MavenExecutionRequest {
44      // ----------------------------------------------------------------------
45      // Logging
46      // ----------------------------------------------------------------------
47  
48      int LOGGING_LEVEL_DEBUG = Logger.LEVEL_DEBUG;
49  
50      int LOGGING_LEVEL_INFO = Logger.LEVEL_INFO;
51  
52      int LOGGING_LEVEL_WARN = Logger.LEVEL_WARN;
53  
54      int LOGGING_LEVEL_ERROR = Logger.LEVEL_ERROR;
55  
56      int LOGGING_LEVEL_FATAL = Logger.LEVEL_FATAL;
57  
58      int LOGGING_LEVEL_DISABLED = Logger.LEVEL_DISABLED;
59  
60      // ----------------------------------------------------------------------
61      // Reactor Failure Mode
62      // ----------------------------------------------------------------------
63  
64      String REACTOR_FAIL_FAST = "FAIL_FAST";
65  
66      String REACTOR_FAIL_AT_END = "FAIL_AT_END";
67  
68      String REACTOR_FAIL_NEVER = "FAIL_NEVER";
69  
70      // ----------------------------------------------------------------------
71      // Reactor Make Mode
72      // ----------------------------------------------------------------------
73  
74      String REACTOR_MAKE_UPSTREAM = "make-upstream";
75  
76      String REACTOR_MAKE_DOWNSTREAM = "make-downstream";
77  
78      String REACTOR_MAKE_BOTH = "make-both";
79  
80      // ----------------------------------------------------------------------
81      // Artifact repository policies
82      // ----------------------------------------------------------------------
83  
84      String CHECKSUM_POLICY_FAIL = ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL;
85  
86      String CHECKSUM_POLICY_WARN = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
87  
88      // ----------------------------------------------------------------------
89      //
90      // ----------------------------------------------------------------------
91  
92      // Base directory
93      MavenExecutionRequest setBaseDirectory(File basedir);
94  
95      String getBaseDirectory();
96  
97      // Timing (remove this)
98      MavenExecutionRequest setStartTime(Date start);
99  
100     Date getStartTime();
101 
102     // Goals
103     MavenExecutionRequest setGoals(List<String> goals);
104 
105     List<String> getGoals();
106 
107     // Properties
108 
109     /**
110      * Sets the system properties to use for interpolation and profile activation. The system properties are collected
111      * from the runtime environment like {@link System#getProperties()} and environment variables.
112      *
113      * @param systemProperties The system properties, may be {@code null}.
114      * @return This request, never {@code null}.
115      */
116     MavenExecutionRequest setSystemProperties(Properties systemProperties);
117 
118     /**
119      * Gets the system properties to use for interpolation and profile activation. The system properties are collected
120      * from the runtime environment like {@link System#getProperties()} and environment variables.
121      *
122      * @return The system properties, never {@code null}.
123      */
124     Properties getSystemProperties();
125 
126     /**
127      * Sets the user properties to use for interpolation and profile activation. The user properties have been
128      * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
129      * line.
130      *
131      * @param userProperties The user properties, may be {@code null}.
132      * @return This request, never {@code null}.
133      */
134     MavenExecutionRequest setUserProperties(Properties userProperties);
135 
136     /**
137      * Gets the user properties to use for interpolation and profile activation. The user properties have been
138      * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
139      * line.
140      *
141      * @return The user properties, never {@code null}.
142      */
143     Properties getUserProperties();
144 
145     // Reactor
146     MavenExecutionRequest setReactorFailureBehavior(String failureBehavior);
147 
148     String getReactorFailureBehavior();
149 
150     /**
151      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
152      */
153     @Deprecated
154     MavenExecutionRequest setSelectedProjects(List<String> projects);
155 
156     /**
157      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
158      */
159     @Deprecated
160     List<String> getSelectedProjects();
161 
162     /**
163      * @param projects the projects to exclude
164      * @return this MavenExecutionRequest
165      * @since 3.2
166      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
167      */
168     @Deprecated
169     MavenExecutionRequest setExcludedProjects(List<String> projects);
170 
171     /**
172      * @return the excluded projects, never {@code null}
173      * @since 3.2
174      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
175      */
176     @Deprecated
177     List<String> getExcludedProjects();
178 
179     /**
180      * Sets whether the build should be resumed from the data in the resume.properties file.
181      * @param resume Whether or not to resume a previous build.
182      * @return This request, never {@code null}.
183      */
184     MavenExecutionRequest setResume(boolean resume);
185 
186     /**
187      * @return Whether the build should be resumed from the data in the resume.properties file.
188      */
189     boolean isResume();
190 
191     MavenExecutionRequest setResumeFrom(String project);
192 
193     String getResumeFrom();
194 
195     MavenExecutionRequest setMakeBehavior(String makeBehavior);
196 
197     String getMakeBehavior();
198 
199     /**
200      * Set's the parallel degree of concurrency used by the build.
201      *
202      * @param degreeOfConcurrency
203      */
204     void setDegreeOfConcurrency(int degreeOfConcurrency);
205 
206     /**
207      * @return the degree of concurrency for the build.
208      */
209     int getDegreeOfConcurrency();
210 
211     // Recursive (really to just process the top-level POM)
212     MavenExecutionRequest setRecursive(boolean recursive);
213 
214     boolean isRecursive();
215 
216     MavenExecutionRequest setPom(File pom);
217 
218     File getPom();
219 
220     // Errors
221     MavenExecutionRequest setShowErrors(boolean showErrors);
222 
223     boolean isShowErrors();
224 
225     // Transfer listeners
226     MavenExecutionRequest setTransferListener(TransferListener transferListener);
227 
228     TransferListener getTransferListener();
229 
230     // Logging
231     MavenExecutionRequest setLoggingLevel(int loggingLevel);
232 
233     int getLoggingLevel();
234 
235     // Update snapshots
236     MavenExecutionRequest setUpdateSnapshots(boolean updateSnapshots);
237 
238     boolean isUpdateSnapshots();
239 
240     MavenExecutionRequest setNoSnapshotUpdates(boolean noSnapshotUpdates);
241 
242     boolean isNoSnapshotUpdates();
243 
244     // Checksum policy
245     MavenExecutionRequest setGlobalChecksumPolicy(String globalChecksumPolicy);
246 
247     String getGlobalChecksumPolicy();
248 
249     // Local repository
250     MavenExecutionRequest setLocalRepositoryPath(String localRepository);
251 
252     MavenExecutionRequest setLocalRepositoryPath(File localRepository);
253 
254     File getLocalRepositoryPath();
255 
256     MavenExecutionRequest setLocalRepository(ArtifactRepository repository);
257 
258     ArtifactRepository getLocalRepository();
259 
260     // Interactive
261     MavenExecutionRequest setInteractiveMode(boolean interactive);
262 
263     boolean isInteractiveMode();
264 
265     // Offline
266     MavenExecutionRequest setOffline(boolean offline);
267 
268     boolean isOffline();
269 
270     boolean isCacheTransferError();
271 
272     MavenExecutionRequest setCacheTransferError(boolean cacheTransferError);
273 
274     boolean isCacheNotFound();
275 
276     MavenExecutionRequest setCacheNotFound(boolean cacheNotFound);
277 
278     // Profiles
279     List<Profile> getProfiles();
280 
281     MavenExecutionRequest addProfile(Profile profile);
282 
283     MavenExecutionRequest setProfiles(List<Profile> profiles);
284 
285     /**
286      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
287      */
288     @Deprecated
289     MavenExecutionRequest addActiveProfile(String profile);
290 
291     /**
292      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
293      */
294     @Deprecated
295     MavenExecutionRequest addActiveProfiles(List<String> profiles);
296 
297     /**
298      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
299      */
300     @Deprecated
301     MavenExecutionRequest setActiveProfiles(List<String> profiles);
302 
303     /**
304      * @return The list of profiles that the user wants to activate.
305      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
306      */
307     @Deprecated
308     List<String> getActiveProfiles();
309 
310     /**
311      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
312      */
313     @Deprecated
314     MavenExecutionRequest addInactiveProfile(String profile);
315 
316     /**
317      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
318      */
319     @Deprecated
320     MavenExecutionRequest addInactiveProfiles(List<String> profiles);
321 
322     /**
323      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
324      */
325     @Deprecated
326     MavenExecutionRequest setInactiveProfiles(List<String> profiles);
327 
328     /**
329      * @return The list of profiles that the user wants to de-activate.
330      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
331      */
332     @Deprecated
333     List<String> getInactiveProfiles();
334 
335     /**
336      * Return the requested activation(s) of project(s) in this execution.
337      * @return requested (de-)activation(s) of project(s) in this execution. Never {@code null}.
338      */
339     ProjectActivation getProjectActivation();
340 
341     /**
342      * Return the requested activation(s) of profile(s) in this execution.
343      * @return requested (de-)activation(s) of profile(s) in this execution. Never {@code null}.
344      */
345     ProfileActivation getProfileActivation();
346 
347     // Proxies
348     List<Proxy> getProxies();
349 
350     MavenExecutionRequest setProxies(List<Proxy> proxies);
351 
352     MavenExecutionRequest addProxy(Proxy proxy);
353 
354     // Servers
355     List<Server> getServers();
356 
357     MavenExecutionRequest setServers(List<Server> servers);
358 
359     MavenExecutionRequest addServer(Server server);
360 
361     // Mirrors
362     List<Mirror> getMirrors();
363 
364     MavenExecutionRequest setMirrors(List<Mirror> mirrors);
365 
366     MavenExecutionRequest addMirror(Mirror mirror);
367 
368     // Plugin groups
369     List<String> getPluginGroups();
370 
371     MavenExecutionRequest setPluginGroups(List<String> pluginGroups);
372 
373     MavenExecutionRequest addPluginGroup(String pluginGroup);
374 
375     MavenExecutionRequest addPluginGroups(List<String> pluginGroups);
376 
377     boolean isProjectPresent();
378 
379     MavenExecutionRequest setProjectPresent(boolean isProjectPresent);
380 
381     File getUserSettingsFile();
382 
383     MavenExecutionRequest setUserSettingsFile(File userSettingsFile);
384 
385     File getGlobalSettingsFile();
386 
387     MavenExecutionRequest setGlobalSettingsFile(File globalSettingsFile);
388 
389     MavenExecutionRequest addRemoteRepository(ArtifactRepository repository);
390 
391     MavenExecutionRequest addPluginArtifactRepository(ArtifactRepository repository);
392 
393     /**
394      * Set a new list of remote repositories to use the execution request. This is necessary if you perform
395      * transformations on the remote repositories being used. For example if you replace existing repositories with
396      * mirrors then it's easier to just replace the whole list with a new list of transformed repositories.
397      *
398      * @param repositories
399      * @return This request, never {@code null}.
400      */
401     MavenExecutionRequest setRemoteRepositories(List<ArtifactRepository> repositories);
402 
403     List<ArtifactRepository> getRemoteRepositories();
404 
405     MavenExecutionRequest setPluginArtifactRepositories(List<ArtifactRepository> repositories);
406 
407     List<ArtifactRepository> getPluginArtifactRepositories();
408 
409     MavenExecutionRequest setRepositoryCache(RepositoryCache repositoryCache);
410 
411     RepositoryCache getRepositoryCache();
412 
413     WorkspaceReader getWorkspaceReader();
414 
415     MavenExecutionRequest setWorkspaceReader(WorkspaceReader workspaceReader);
416 
417     File getUserToolchainsFile();
418 
419     MavenExecutionRequest setUserToolchainsFile(File userToolchainsFile);
420 
421     /**
422      *
423      *
424      * @return the global toolchains file
425      * @since 3.3.0
426      */
427     File getGlobalToolchainsFile();
428 
429     /**
430      *
431      * @param globalToolchainsFile the global toolchains file
432      * @return this request
433      * @since 3.3.0
434      */
435     MavenExecutionRequest setGlobalToolchainsFile(File globalToolchainsFile);
436 
437     ExecutionListener getExecutionListener();
438 
439     MavenExecutionRequest setExecutionListener(ExecutionListener executionListener);
440 
441     ProjectBuildingRequest getProjectBuildingRequest();
442 
443     /**
444      * @since 3.1
445      */
446     boolean isUseLegacyLocalRepository();
447 
448     /**
449      * @since 3.1
450      */
451     MavenExecutionRequest setUseLegacyLocalRepository(boolean useLegacyLocalRepository);
452 
453     /**
454      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
455      * of the builder's id.
456      *
457      * @since 3.2.0
458      */
459     MavenExecutionRequest setBuilderId(String builderId);
460 
461     /**
462      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
463      * of the builders id.
464      *
465      * @since 3.2.0
466      */
467     String getBuilderId();
468 
469     /**
470      *
471      * @param toolchains all toolchains grouped by type
472      * @return this request
473      * @since 3.3.0
474      */
475     MavenExecutionRequest setToolchains(Map<String, List<ToolchainModel>> toolchains);
476 
477     /**
478      *
479      * @return all toolchains grouped by type, never {@code null}
480      * @since 3.3.0
481      */
482     Map<String, List<ToolchainModel>> getToolchains();
483 
484     /**
485      * @since 3.3.0
486      */
487     void setMultiModuleProjectDirectory(File file);
488 
489     /**
490      * @since 3.3.0
491      */
492     File getMultiModuleProjectDirectory();
493 
494     /**
495      * @since 3.3.0
496      */
497     MavenExecutionRequest setEventSpyDispatcher(EventSpyDispatcher eventSpyDispatcher);
498 
499     /**
500      * @since 3.3.0
501      */
502     EventSpyDispatcher getEventSpyDispatcher();
503 
504     /**
505      * @since 3.3.0
506      */
507     Map<String, Object> getData();
508 }