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