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     MavenExecutionRequest setSelectedProjects(List<String> projects);
152 
153     List<String> getSelectedProjects();
154 
155     /**
156      * @param projects the projects to exclude
157      * @return this MavenExecutionRequest
158      * @since 3.2
159      */
160     MavenExecutionRequest setExcludedProjects(List<String> projects);
161 
162     /**
163      * @return the excluded projects, never {@code null}
164      * @since 3.2
165      */
166     List<String> getExcludedProjects();
167 
168     MavenExecutionRequest setResumeFrom(String project);
169 
170     String getResumeFrom();
171 
172     MavenExecutionRequest setMakeBehavior(String makeBehavior);
173 
174     String getMakeBehavior();
175 
176     /**
177      * Set's the parallel degree of concurrency used by the build.
178      *
179      * @param degreeOfConcurrency
180      */
181     void setDegreeOfConcurrency(int degreeOfConcurrency);
182 
183     /**
184      * @return the degree of concurrency for the build.
185      */
186     int getDegreeOfConcurrency();
187 
188     // Recursive (really to just process the top-level POM)
189     MavenExecutionRequest setRecursive(boolean recursive);
190 
191     boolean isRecursive();
192 
193     MavenExecutionRequest setPom(File pom);
194 
195     File getPom();
196 
197     // Errors
198     MavenExecutionRequest setShowErrors(boolean showErrors);
199 
200     boolean isShowErrors();
201 
202     // Transfer listeners
203     MavenExecutionRequest setTransferListener(TransferListener transferListener);
204 
205     TransferListener getTransferListener();
206 
207     // Logging
208     MavenExecutionRequest setLoggingLevel(int loggingLevel);
209 
210     int getLoggingLevel();
211 
212     // Update snapshots
213     MavenExecutionRequest setUpdateSnapshots(boolean updateSnapshots);
214 
215     boolean isUpdateSnapshots();
216 
217     MavenExecutionRequest setNoSnapshotUpdates(boolean noSnapshotUpdates);
218 
219     boolean isNoSnapshotUpdates();
220 
221     // Checksum policy
222     MavenExecutionRequest setGlobalChecksumPolicy(String globalChecksumPolicy);
223 
224     String getGlobalChecksumPolicy();
225 
226     // Local repository
227     MavenExecutionRequest setLocalRepositoryPath(String localRepository);
228 
229     MavenExecutionRequest setLocalRepositoryPath(File localRepository);
230 
231     File getLocalRepositoryPath();
232 
233     MavenExecutionRequest setLocalRepository(ArtifactRepository repository);
234 
235     ArtifactRepository getLocalRepository();
236 
237     // Interactive
238     MavenExecutionRequest setInteractiveMode(boolean interactive);
239 
240     boolean isInteractiveMode();
241 
242     // Offline
243     MavenExecutionRequest setOffline(boolean offline);
244 
245     boolean isOffline();
246 
247     boolean isCacheTransferError();
248 
249     MavenExecutionRequest setCacheTransferError(boolean cacheTransferError);
250 
251     boolean isCacheNotFound();
252 
253     MavenExecutionRequest setCacheNotFound(boolean cacheNotFound);
254 
255     /**
256      * @since 3.9.7
257      */
258     boolean isIgnoreTransitiveRepositories();
259 
260     /**
261      * @since 3.9.7
262      */
263     MavenExecutionRequest setIgnoreTransitiveRepositories(boolean ignoreTransitiveRepositories);
264 
265     // Profiles
266     List<Profile> getProfiles();
267 
268     MavenExecutionRequest addProfile(Profile profile);
269 
270     MavenExecutionRequest setProfiles(List<Profile> profiles);
271 
272     MavenExecutionRequest addActiveProfile(String profile);
273 
274     MavenExecutionRequest addActiveProfiles(List<String> profiles);
275 
276     MavenExecutionRequest setActiveProfiles(List<String> profiles);
277 
278     List<String> getActiveProfiles();
279 
280     MavenExecutionRequest addInactiveProfile(String profile);
281 
282     MavenExecutionRequest addInactiveProfiles(List<String> profiles);
283 
284     MavenExecutionRequest setInactiveProfiles(List<String> profiles);
285 
286     List<String> getInactiveProfiles();
287 
288     // Proxies
289     List<Proxy> getProxies();
290 
291     MavenExecutionRequest setProxies(List<Proxy> proxies);
292 
293     MavenExecutionRequest addProxy(Proxy proxy);
294 
295     // Servers
296     List<Server> getServers();
297 
298     MavenExecutionRequest setServers(List<Server> servers);
299 
300     MavenExecutionRequest addServer(Server server);
301 
302     // Mirrors
303     List<Mirror> getMirrors();
304 
305     MavenExecutionRequest setMirrors(List<Mirror> mirrors);
306 
307     MavenExecutionRequest addMirror(Mirror mirror);
308 
309     // Plugin groups
310     List<String> getPluginGroups();
311 
312     MavenExecutionRequest setPluginGroups(List<String> pluginGroups);
313 
314     MavenExecutionRequest addPluginGroup(String pluginGroup);
315 
316     MavenExecutionRequest addPluginGroups(List<String> pluginGroups);
317 
318     boolean isProjectPresent();
319 
320     MavenExecutionRequest setProjectPresent(boolean isProjectPresent);
321 
322     File getUserSettingsFile();
323 
324     MavenExecutionRequest setUserSettingsFile(File userSettingsFile);
325 
326     File getGlobalSettingsFile();
327 
328     MavenExecutionRequest setGlobalSettingsFile(File globalSettingsFile);
329 
330     MavenExecutionRequest addRemoteRepository(ArtifactRepository repository);
331 
332     MavenExecutionRequest addPluginArtifactRepository(ArtifactRepository repository);
333 
334     /**
335      * Set a new list of remote repositories to use the execution request. This is necessary if you perform
336      * transformations on the remote repositories being used. For example if you replace existing repositories with
337      * mirrors then it's easier to just replace the whole list with a new list of transformed repositories.
338      *
339      * @param repositories
340      * @return This request, never {@code null}.
341      */
342     MavenExecutionRequest setRemoteRepositories(List<ArtifactRepository> repositories);
343 
344     List<ArtifactRepository> getRemoteRepositories();
345 
346     MavenExecutionRequest setPluginArtifactRepositories(List<ArtifactRepository> repositories);
347 
348     List<ArtifactRepository> getPluginArtifactRepositories();
349 
350     MavenExecutionRequest setRepositoryCache(RepositoryCache repositoryCache);
351 
352     RepositoryCache getRepositoryCache();
353 
354     WorkspaceReader getWorkspaceReader();
355 
356     MavenExecutionRequest setWorkspaceReader(WorkspaceReader workspaceReader);
357 
358     File getUserToolchainsFile();
359 
360     MavenExecutionRequest setUserToolchainsFile(File userToolchainsFile);
361 
362     /**
363      *
364      *
365      * @return the global toolchains file
366      * @since 3.3.0
367      */
368     File getGlobalToolchainsFile();
369 
370     /**
371      *
372      * @param globalToolchainsFile the global toolchains file
373      * @return this request
374      * @since 3.3.0
375      */
376     MavenExecutionRequest setGlobalToolchainsFile(File globalToolchainsFile);
377 
378     ExecutionListener getExecutionListener();
379 
380     MavenExecutionRequest setExecutionListener(ExecutionListener executionListener);
381 
382     ProjectBuildingRequest getProjectBuildingRequest();
383 
384     /**
385      * @since 3.1
386      * @deprecated Since 3.9 there is no direct Maven2 interop offered at LRM level. See
387      * <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration</a> page option
388      * {@code aether.artifactResolver.simpleLrmInterop} that provides similar semantics. This method should
389      * be never invoked, and always returns {@code false}.
390      */
391     @Deprecated
392     boolean isUseLegacyLocalRepository();
393 
394     /**
395      * @since 3.1
396      * @deprecated Since 3.9 there is no direct Maven2 interop offered at LRM level. See
397      * <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration</a> page option
398      * {@code aether.artifactResolver.simpleLrmInterop} that provides similar semantics. This method should
399      * be never invoked, and ignores parameter (value remains always {@code false}).     */
400     @Deprecated
401     MavenExecutionRequest setUseLegacyLocalRepository(boolean useLegacyLocalRepository);
402 
403     /**
404      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
405      * of the builder's id.
406      *
407      * @since 3.2.0
408      */
409     MavenExecutionRequest setBuilderId(String builderId);
410 
411     /**
412      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
413      * of the builders id.
414      *
415      * @since 3.2.0
416      */
417     String getBuilderId();
418 
419     /**
420      *
421      * @param toolchains all toolchains grouped by type
422      * @return this request
423      * @since 3.3.0
424      */
425     MavenExecutionRequest setToolchains(Map<String, List<ToolchainModel>> toolchains);
426 
427     /**
428      *
429      * @return all toolchains grouped by type, never {@code null}
430      * @since 3.3.0
431      */
432     Map<String, List<ToolchainModel>> getToolchains();
433 
434     /**
435      * @since 3.3.0
436      */
437     void setMultiModuleProjectDirectory(File file);
438 
439     /**
440      * @since 3.3.0
441      */
442     File getMultiModuleProjectDirectory();
443 
444     /**
445      * @since 3.3.0
446      */
447     MavenExecutionRequest setEventSpyDispatcher(EventSpyDispatcher eventSpyDispatcher);
448 
449     /**
450      * @since 3.3.0
451      */
452     EventSpyDispatcher getEventSpyDispatcher();
453 
454     /**
455      * @since 3.3.0
456      */
457     Map<String, Object> getData();
458 }