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