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