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     // Profiles
256     List<Profile> getProfiles();
257 
258     MavenExecutionRequest addProfile(Profile profile);
259 
260     MavenExecutionRequest setProfiles(List<Profile> profiles);
261 
262     MavenExecutionRequest addActiveProfile(String profile);
263 
264     MavenExecutionRequest addActiveProfiles(List<String> profiles);
265 
266     MavenExecutionRequest setActiveProfiles(List<String> profiles);
267 
268     List<String> getActiveProfiles();
269 
270     MavenExecutionRequest addInactiveProfile(String profile);
271 
272     MavenExecutionRequest addInactiveProfiles(List<String> profiles);
273 
274     MavenExecutionRequest setInactiveProfiles(List<String> profiles);
275 
276     List<String> getInactiveProfiles();
277 
278     // Proxies
279     List<Proxy> getProxies();
280 
281     MavenExecutionRequest setProxies(List<Proxy> proxies);
282 
283     MavenExecutionRequest addProxy(Proxy proxy);
284 
285     // Servers
286     List<Server> getServers();
287 
288     MavenExecutionRequest setServers(List<Server> servers);
289 
290     MavenExecutionRequest addServer(Server server);
291 
292     // Mirrors
293     List<Mirror> getMirrors();
294 
295     MavenExecutionRequest setMirrors(List<Mirror> mirrors);
296 
297     MavenExecutionRequest addMirror(Mirror mirror);
298 
299     // Plugin groups
300     List<String> getPluginGroups();
301 
302     MavenExecutionRequest setPluginGroups(List<String> pluginGroups);
303 
304     MavenExecutionRequest addPluginGroup(String pluginGroup);
305 
306     MavenExecutionRequest addPluginGroups(List<String> pluginGroups);
307 
308     boolean isProjectPresent();
309 
310     MavenExecutionRequest setProjectPresent(boolean isProjectPresent);
311 
312     File getUserSettingsFile();
313 
314     MavenExecutionRequest setUserSettingsFile(File userSettingsFile);
315 
316     File getGlobalSettingsFile();
317 
318     MavenExecutionRequest setGlobalSettingsFile(File globalSettingsFile);
319 
320     MavenExecutionRequest addRemoteRepository(ArtifactRepository repository);
321 
322     MavenExecutionRequest addPluginArtifactRepository(ArtifactRepository repository);
323 
324     /**
325      * Set a new list of remote repositories to use the execution request. This is necessary if you perform
326      * transformations on the remote repositories being used. For example if you replace existing repositories with
327      * mirrors then it's easier to just replace the whole list with a new list of transformed repositories.
328      *
329      * @param repositories
330      * @return This request, never {@code null}.
331      */
332     MavenExecutionRequest setRemoteRepositories(List<ArtifactRepository> repositories);
333 
334     List<ArtifactRepository> getRemoteRepositories();
335 
336     MavenExecutionRequest setPluginArtifactRepositories(List<ArtifactRepository> repositories);
337 
338     List<ArtifactRepository> getPluginArtifactRepositories();
339 
340     MavenExecutionRequest setRepositoryCache(RepositoryCache repositoryCache);
341 
342     RepositoryCache getRepositoryCache();
343 
344     WorkspaceReader getWorkspaceReader();
345 
346     MavenExecutionRequest setWorkspaceReader(WorkspaceReader workspaceReader);
347 
348     File getUserToolchainsFile();
349 
350     MavenExecutionRequest setUserToolchainsFile(File userToolchainsFile);
351 
352     /**
353      *
354      *
355      * @return the global toolchains file
356      * @since 3.3.0
357      */
358     File getGlobalToolchainsFile();
359 
360     /**
361      *
362      * @param globalToolchainsFile the global toolchains file
363      * @return this request
364      * @since 3.3.0
365      */
366     MavenExecutionRequest setGlobalToolchainsFile(File globalToolchainsFile);
367 
368     ExecutionListener getExecutionListener();
369 
370     MavenExecutionRequest setExecutionListener(ExecutionListener executionListener);
371 
372     ProjectBuildingRequest getProjectBuildingRequest();
373 
374     /**
375      * @since 3.1
376      * @deprecated Since 3.9 there is no direct Maven2 interop offered at LRM level. See
377      * <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration</a> page option
378      * {@code aether.artifactResolver.simpleLrmInterop} that provides similar semantics. This method should
379      * be never invoked, and always returns {@code false}.
380      */
381     @Deprecated
382     boolean isUseLegacyLocalRepository();
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 ignores parameter (value remains always {@code false}).     */
390     @Deprecated
391     MavenExecutionRequest setUseLegacyLocalRepository(boolean useLegacyLocalRepository);
392 
393     /**
394      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
395      * of the builder's id.
396      *
397      * @since 3.2.0
398      */
399     MavenExecutionRequest setBuilderId(String builderId);
400 
401     /**
402      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
403      * of the builders id.
404      *
405      * @since 3.2.0
406      */
407     String getBuilderId();
408 
409     /**
410      *
411      * @param toolchains all toolchains grouped by type
412      * @return this request
413      * @since 3.3.0
414      */
415     MavenExecutionRequest setToolchains(Map<String, List<ToolchainModel>> toolchains);
416 
417     /**
418      *
419      * @return all toolchains grouped by type, never {@code null}
420      * @since 3.3.0
421      */
422     Map<String, List<ToolchainModel>> getToolchains();
423 
424     /**
425      * @since 3.3.0
426      */
427     void setMultiModuleProjectDirectory(File file);
428 
429     /**
430      * @since 3.3.0
431      */
432     File getMultiModuleProjectDirectory();
433 
434     /**
435      * @since 3.3.0
436      */
437     MavenExecutionRequest setEventSpyDispatcher(EventSpyDispatcher eventSpyDispatcher);
438 
439     /**
440      * @since 3.3.0
441      */
442     EventSpyDispatcher getEventSpyDispatcher();
443 
444     /**
445      * @since 3.3.0
446      */
447     Map<String, Object> getData();
448 }