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      MavenExecutionRequest setBaseDirectory(File basedir);
96  
97      String getBaseDirectory();
98  
99      // Timing (remove this)
100     MavenExecutionRequest setStartTime(Date start);
101 
102     Date getStartTime();
103 
104     // Goals
105     MavenExecutionRequest setGoals(List<String> goals);
106 
107     List<String> getGoals();
108 
109     // Properties
110 
111     /**
112      * Sets the system properties to use for interpolation and profile activation. The system properties are collected
113      * from the runtime environment like {@link System#getProperties()} and environment variables.
114      *
115      * @param systemProperties The system properties, may be {@code null}.
116      * @return This request, never {@code null}.
117      */
118     MavenExecutionRequest setSystemProperties(Properties systemProperties);
119 
120     /**
121      * Gets 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      * @return The system properties, never {@code null}.
125      */
126     Properties getSystemProperties();
127 
128     /**
129      * Sets the user properties to use for interpolation and profile activation. The user properties have been
130      * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
131      * line.
132      *
133      * @param userProperties The user properties, may be {@code null}.
134      * @return This request, never {@code null}.
135      */
136     MavenExecutionRequest setUserProperties(Properties userProperties);
137 
138     /**
139      * Gets the user properties to use for interpolation and profile activation. The user properties have been
140      * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
141      * line.
142      *
143      * @return The user properties, never {@code null}.
144      */
145     Properties getUserProperties();
146 
147     // Reactor
148     MavenExecutionRequest setReactorFailureBehavior(String failureBehavior);
149 
150     String getReactorFailureBehavior();
151 
152     MavenExecutionRequest setSelectedProjects(List<String> projects);
153 
154     List<String> getSelectedProjects();
155 
156     /**
157      * @param projects the projects to exclude
158      * @return this MavenExecutionRequest
159      * @since 3.2
160      */
161     MavenExecutionRequest setExcludedProjects(List<String> projects);
162 
163     /**
164      * @return the excluded projects, never {@code null}
165      * @since 3.2
166      */
167     List<String> getExcludedProjects();
168 
169     MavenExecutionRequest setResumeFrom(String project);
170 
171     String getResumeFrom();
172 
173     MavenExecutionRequest setMakeBehavior(String makeBehavior);
174 
175     String getMakeBehavior();
176 
177     /**
178      * Set's the parallel degree of concurrency used by the build.
179      *
180      * @param degreeOfConcurrency
181      */
182     void setDegreeOfConcurrency(int degreeOfConcurrency);
183 
184     /**
185      * @return the degree of concurrency for the build.
186      */
187     int getDegreeOfConcurrency();
188 
189     // Recursive (really to just process the top-level POM)
190     MavenExecutionRequest setRecursive(boolean recursive);
191 
192     boolean isRecursive();
193 
194     MavenExecutionRequest setPom(File pom);
195 
196     File getPom();
197 
198     // Errors
199     MavenExecutionRequest setShowErrors(boolean showErrors);
200 
201     boolean isShowErrors();
202 
203     // Transfer listeners
204     MavenExecutionRequest setTransferListener(TransferListener transferListener);
205 
206     TransferListener getTransferListener();
207 
208     // Logging
209     MavenExecutionRequest setLoggingLevel(int loggingLevel);
210 
211     int getLoggingLevel();
212 
213     // Update snapshots
214     MavenExecutionRequest setUpdateSnapshots(boolean updateSnapshots);
215 
216     boolean isUpdateSnapshots();
217 
218     MavenExecutionRequest setNoSnapshotUpdates(boolean noSnapshotUpdates);
219 
220     boolean isNoSnapshotUpdates();
221 
222     // 3.10.x+ artifact and metadata policies
223 
224     /**
225      * @since 3.10.0
226      */
227     MavenExecutionRequest setArtifactsUpdatePolicy(String policy);
228 
229     /**
230      * @since 3.10.0
231      */
232     String getArtifactsUpdatePolicy();
233 
234     /**
235      * @since 3.10.0
236      */
237     MavenExecutionRequest setMetadataUpdatePolicy(String policy);
238 
239     /**
240      * @since 3.10.0
241      */
242     String getMetadataUpdatePolicy();
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     /**
279      * @since 3.9.7
280      */
281     boolean isIgnoreTransitiveRepositories();
282 
283     /**
284      * @since 3.9.7
285      */
286     MavenExecutionRequest setIgnoreTransitiveRepositories(boolean ignoreTransitiveRepositories);
287 
288     // Profiles
289     List<Profile> getProfiles();
290 
291     MavenExecutionRequest addProfile(Profile profile);
292 
293     MavenExecutionRequest setProfiles(List<Profile> profiles);
294 
295     MavenExecutionRequest addActiveProfile(String profile);
296 
297     MavenExecutionRequest addActiveProfiles(List<String> profiles);
298 
299     MavenExecutionRequest setActiveProfiles(List<String> profiles);
300 
301     List<String> getActiveProfiles();
302 
303     MavenExecutionRequest addInactiveProfile(String profile);
304 
305     MavenExecutionRequest addInactiveProfiles(List<String> profiles);
306 
307     MavenExecutionRequest setInactiveProfiles(List<String> profiles);
308 
309     List<String> getInactiveProfiles();
310 
311     // Proxies
312     List<Proxy> getProxies();
313 
314     MavenExecutionRequest setProxies(List<Proxy> proxies);
315 
316     MavenExecutionRequest addProxy(Proxy proxy);
317 
318     // Servers
319     List<Server> getServers();
320 
321     MavenExecutionRequest setServers(List<Server> servers);
322 
323     MavenExecutionRequest addServer(Server server);
324 
325     // Mirrors
326     List<Mirror> getMirrors();
327 
328     MavenExecutionRequest setMirrors(List<Mirror> mirrors);
329 
330     MavenExecutionRequest addMirror(Mirror mirror);
331 
332     // Plugin groups
333     List<String> getPluginGroups();
334 
335     MavenExecutionRequest setPluginGroups(List<String> pluginGroups);
336 
337     MavenExecutionRequest addPluginGroup(String pluginGroup);
338 
339     MavenExecutionRequest addPluginGroups(List<String> pluginGroups);
340 
341     boolean isProjectPresent();
342 
343     MavenExecutionRequest setProjectPresent(boolean isProjectPresent);
344 
345     File getUserSettingsFile();
346 
347     MavenExecutionRequest setUserSettingsFile(File userSettingsFile);
348 
349     File getGlobalSettingsFile();
350 
351     MavenExecutionRequest setGlobalSettingsFile(File globalSettingsFile);
352 
353     MavenExecutionRequest addRemoteRepository(ArtifactRepository repository);
354 
355     MavenExecutionRequest addPluginArtifactRepository(ArtifactRepository repository);
356 
357     /**
358      * Set a new list of remote repositories to use the execution request. This is necessary if you perform
359      * transformations on the remote repositories being used. For example if you replace existing repositories with
360      * mirrors then it's easier to just replace the whole list with a new list of transformed repositories.
361      *
362      * @param repositories
363      * @return This request, never {@code null}.
364      */
365     MavenExecutionRequest setRemoteRepositories(List<ArtifactRepository> repositories);
366 
367     List<ArtifactRepository> getRemoteRepositories();
368 
369     MavenExecutionRequest setPluginArtifactRepositories(List<ArtifactRepository> repositories);
370 
371     List<ArtifactRepository> getPluginArtifactRepositories();
372 
373     MavenExecutionRequest setRepositoryCache(RepositoryCache repositoryCache);
374 
375     RepositoryCache getRepositoryCache();
376 
377     WorkspaceReader getWorkspaceReader();
378 
379     MavenExecutionRequest setWorkspaceReader(WorkspaceReader workspaceReader);
380 
381     File getUserToolchainsFile();
382 
383     MavenExecutionRequest setUserToolchainsFile(File userToolchainsFile);
384 
385     /**
386      *
387      *
388      * @return the global toolchains file
389      * @since 3.3.0
390      */
391     File getGlobalToolchainsFile();
392 
393     /**
394      *
395      * @param globalToolchainsFile the global toolchains file
396      * @return this request
397      * @since 3.3.0
398      */
399     MavenExecutionRequest setGlobalToolchainsFile(File globalToolchainsFile);
400 
401     ExecutionListener getExecutionListener();
402 
403     MavenExecutionRequest setExecutionListener(ExecutionListener executionListener);
404 
405     ProjectBuildingRequest getProjectBuildingRequest();
406 
407     /**
408      * @since 3.1
409      * @deprecated Since 3.9 there is no direct Maven2 interop offered at LRM level. See
410      * <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration</a> page option
411      * {@code aether.artifactResolver.simpleLrmInterop} that provides similar semantics. This method should
412      * be never invoked, and always returns {@code false}.
413      */
414     @Deprecated
415     boolean isUseLegacyLocalRepository();
416 
417     /**
418      * @since 3.1
419      * @deprecated Since 3.9 there is no direct Maven2 interop offered at LRM level. See
420      * <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration</a> page option
421      * {@code aether.artifactResolver.simpleLrmInterop} that provides similar semantics. This method should
422      * be never invoked, and ignores parameter (value remains always {@code false}).     */
423     @Deprecated
424     MavenExecutionRequest setUseLegacyLocalRepository(boolean useLegacyLocalRepository);
425 
426     /**
427      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
428      * of the builder's id.
429      *
430      * @since 3.2.0
431      */
432     MavenExecutionRequest setBuilderId(String builderId);
433 
434     /**
435      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
436      * of the builders id.
437      *
438      * @since 3.2.0
439      */
440     String getBuilderId();
441 
442     /**
443      *
444      * @param toolchains all toolchains grouped by type
445      * @return this request
446      * @since 3.3.0
447      */
448     MavenExecutionRequest setToolchains(Map<String, List<ToolchainModel>> toolchains);
449 
450     /**
451      *
452      * @return all toolchains grouped by type, never {@code null}
453      * @since 3.3.0
454      */
455     Map<String, List<ToolchainModel>> getToolchains();
456 
457     /**
458      * @since 3.3.0
459      */
460     void setMultiModuleProjectDirectory(File file);
461 
462     /**
463      * @since 3.3.0
464      */
465     File getMultiModuleProjectDirectory();
466 
467     /**
468      * @since 3.3.0
469      */
470     MavenExecutionRequest setEventSpyDispatcher(EventSpyDispatcher eventSpyDispatcher);
471 
472     /**
473      * @since 3.3.0
474      */
475     EventSpyDispatcher getEventSpyDispatcher();
476 
477     /**
478      * @since 3.3.0
479      */
480     Map<String, Object> getData();
481 
482     /**
483      * @since 3.10.0
484      */
485     Path getTopDirectory();
486 
487     /**
488      * @since 3.10.0
489      */
490     MavenExecutionRequest setTopDirectory(Path topDirectory);
491 
492     /**
493      * @since 3.10.0
494      */
495     Path getRootDirectory();
496 
497     /**
498      * @since 3.10.0
499      */
500     MavenExecutionRequest setRootDirectory(Path rootDirectory);
501 }