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