View Javadoc
1   package org.apache.maven.execution;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
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  //
34  // These settings values need to be removed and pushed down into a provider of configuration information
35  //
36  import org.apache.maven.settings.Mirror;
37  import org.apache.maven.settings.Proxy;
38  import org.apache.maven.settings.Server;
39  //
40  import org.apache.maven.toolchain.model.ToolchainModel;
41  import org.codehaus.plexus.logging.Logger;
42  import org.eclipse.aether.RepositoryCache;
43  import org.eclipse.aether.repository.WorkspaceReader;
44  import org.eclipse.aether.transfer.TransferListener;
45  
46  /**
47   * @author Jason van Zyl
48   */
49  public interface MavenExecutionRequest
50  {
51      // ----------------------------------------------------------------------
52      // Logging
53      // ----------------------------------------------------------------------
54  
55      int LOGGING_LEVEL_DEBUG = Logger.LEVEL_DEBUG;
56  
57      int LOGGING_LEVEL_INFO = Logger.LEVEL_INFO;
58  
59      int LOGGING_LEVEL_WARN = Logger.LEVEL_WARN;
60  
61      int LOGGING_LEVEL_ERROR = Logger.LEVEL_ERROR;
62  
63      int LOGGING_LEVEL_FATAL = Logger.LEVEL_FATAL;
64  
65      int LOGGING_LEVEL_DISABLED = Logger.LEVEL_DISABLED;
66  
67      // ----------------------------------------------------------------------
68      // Reactor Failure Mode
69      // ----------------------------------------------------------------------
70  
71      String REACTOR_FAIL_FAST = "FAIL_FAST";
72  
73      String REACTOR_FAIL_AT_END = "FAIL_AT_END";
74  
75      String REACTOR_FAIL_NEVER = "FAIL_NEVER";
76  
77      // ----------------------------------------------------------------------
78      // Reactor Make Mode
79      // ----------------------------------------------------------------------
80  
81      String REACTOR_MAKE_UPSTREAM = "make-upstream";
82  
83      String REACTOR_MAKE_DOWNSTREAM = "make-downstream";
84  
85      String REACTOR_MAKE_BOTH = "make-both";
86  
87      // ----------------------------------------------------------------------
88      // Artifact repository policies
89      // ----------------------------------------------------------------------
90  
91      String CHECKSUM_POLICY_FAIL = ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL;
92  
93      String CHECKSUM_POLICY_WARN = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
94  
95      // ----------------------------------------------------------------------
96      //
97      // ----------------------------------------------------------------------
98  
99      // Base directory
100     MavenExecutionRequest setBaseDirectory( File basedir );
101 
102     String getBaseDirectory();
103 
104     // Timing (remove this)
105     MavenExecutionRequest setStartTime( Date start );
106 
107     Date getStartTime();
108 
109     // Goals
110     MavenExecutionRequest setGoals( List<String> goals );
111 
112     List<String> getGoals();
113 
114     // Properties
115 
116     /**
117      * Sets the system properties to use for interpolation and profile activation. The system properties are collected
118      * from the runtime environment like {@link System#getProperties()} and environment variables.
119      *
120      * @param systemProperties The system properties, may be {@code null}.
121      * @return This request, never {@code null}.
122      */
123     MavenExecutionRequest setSystemProperties( Properties systemProperties );
124 
125     /**
126      * Gets the system properties to use for interpolation and profile activation. The system properties are collected
127      * from the runtime environment like {@link System#getProperties()} and environment variables.
128      *
129      * @return The system properties, never {@code null}.
130      */
131     Properties getSystemProperties();
132 
133     /**
134      * Sets the user properties to use for interpolation and profile activation. The user properties have been
135      * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command
136      * line.
137      *
138      * @param userProperties The user properties, may be {@code null}.
139      * @return This request, never {@code null}.
140      */
141     MavenExecutionRequest setUserProperties( Properties userProperties );
142 
143     /**
144      * Gets 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      * @return The user properties, never {@code null}.
149      */
150     Properties getUserProperties();
151 
152     // Reactor
153     MavenExecutionRequest setReactorFailureBehavior( String failureBehavior );
154 
155     String getReactorFailureBehavior();
156 
157     /**
158      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
159      */
160     @Deprecated
161     MavenExecutionRequest setSelectedProjects( List<String> projects );
162 
163     /**
164      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
165      */
166     @Deprecated
167     List<String> getSelectedProjects();
168 
169     /**
170      * @param projects the projects to exclude
171      * @return this MavenExecutionRequest
172      * @since 3.2
173      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
174      */
175     @Deprecated
176     MavenExecutionRequest setExcludedProjects( List<String> projects );
177 
178     /**
179      * @return the excluded projects, never {@code null}
180      * @since 3.2
181      * @deprecated Since Maven 4: use {@link #getProjectActivation()}.
182      */
183     @Deprecated
184     List<String> getExcludedProjects();
185 
186     /**
187      * Sets whether the build should be resumed from the data in the resume.properties file.
188      * @param resume Whether or not to resume a previous build.
189      * @return This request, never {@code null}.
190      */
191     MavenExecutionRequest setResume( boolean resume );
192 
193     /**
194      * @return Whether the build should be resumed from the data in the resume.properties file.
195      */
196     boolean isResume();
197 
198     MavenExecutionRequest setResumeFrom( String project );
199 
200     String getResumeFrom();
201 
202     MavenExecutionRequest setMakeBehavior( String makeBehavior );
203 
204     String getMakeBehavior();
205 
206     /**
207      * Set's the parallel degree of concurrency used by the build.
208      *
209      * @param degreeOfConcurrency
210      */
211     void setDegreeOfConcurrency( int degreeOfConcurrency );
212 
213     /**
214      * @return the degree of concurrency for the build.
215      */
216     int getDegreeOfConcurrency();
217 
218     // Recursive (really to just process the top-level POM)
219     MavenExecutionRequest setRecursive( boolean recursive );
220 
221     boolean isRecursive();
222 
223     MavenExecutionRequest setPom( File pom );
224 
225     File getPom();
226 
227     // Errors
228     MavenExecutionRequest setShowErrors( boolean showErrors );
229 
230     boolean isShowErrors();
231 
232     // Transfer listeners
233     MavenExecutionRequest setTransferListener( TransferListener transferListener );
234 
235     TransferListener getTransferListener();
236 
237     // Logging
238     MavenExecutionRequest setLoggingLevel( int loggingLevel );
239 
240     int getLoggingLevel();
241 
242     // Update snapshots
243     MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots );
244 
245     boolean isUpdateSnapshots();
246 
247     MavenExecutionRequest setNoSnapshotUpdates( boolean noSnapshotUpdates );
248 
249     boolean isNoSnapshotUpdates();
250 
251     // Checksum policy
252     MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy );
253 
254     String getGlobalChecksumPolicy();
255 
256     // Local repository
257     MavenExecutionRequest setLocalRepositoryPath( String localRepository );
258 
259     MavenExecutionRequest setLocalRepositoryPath( File localRepository );
260 
261     File getLocalRepositoryPath();
262 
263     MavenExecutionRequest setLocalRepository( ArtifactRepository repository );
264 
265     ArtifactRepository getLocalRepository();
266 
267     // Interactive
268     MavenExecutionRequest setInteractiveMode( boolean interactive );
269 
270     boolean isInteractiveMode();
271 
272     // Offline
273     MavenExecutionRequest setOffline( boolean offline );
274 
275     boolean isOffline();
276 
277     boolean isCacheTransferError();
278 
279     MavenExecutionRequest setCacheTransferError( boolean cacheTransferError );
280 
281     boolean isCacheNotFound();
282 
283     MavenExecutionRequest setCacheNotFound( boolean cacheNotFound );
284 
285     // Profiles
286     List<Profile> getProfiles();
287 
288     MavenExecutionRequest addProfile( Profile profile );
289 
290     MavenExecutionRequest setProfiles( List<Profile> profiles );
291 
292     /**
293      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
294      */
295     @Deprecated
296     MavenExecutionRequest addActiveProfile( String profile );
297 
298     /**
299      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
300      */
301     @Deprecated
302     MavenExecutionRequest addActiveProfiles( List<String> profiles );
303 
304     /**
305      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
306      */
307     @Deprecated
308     MavenExecutionRequest setActiveProfiles( List<String> profiles );
309 
310     /**
311      * @return The list of profiles that the user wants to activate.
312      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
313      */
314     @Deprecated
315     List<String> getActiveProfiles();
316 
317     /**
318      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
319      */
320     @Deprecated
321     MavenExecutionRequest addInactiveProfile( String profile );
322 
323     /**
324      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
325      */
326     @Deprecated
327     MavenExecutionRequest addInactiveProfiles( List<String> profiles );
328 
329     /**
330      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
331      */
332     @Deprecated
333     MavenExecutionRequest setInactiveProfiles( List<String> profiles );
334 
335     /**
336      * @return The list of profiles that the user wants to de-activate.
337      * @deprecated Since Maven 4: use {@link #getProfileActivation()}.
338      */
339     @Deprecated
340     List<String> getInactiveProfiles();
341 
342     /**
343      * Return the requested activation(s) of project(s) in this execution.
344      * @return requested (de-)activation(s) of project(s) in this execution. Never {@code null}.
345      */
346     ProjectActivation getProjectActivation();
347 
348     /**
349      * Return the requested activation(s) of profile(s) in this execution.
350      * @return requested (de-)activation(s) of profile(s) in this execution. Never {@code null}.
351      */
352     ProfileActivation getProfileActivation();
353 
354     // Proxies
355     List<Proxy> getProxies();
356 
357     MavenExecutionRequest setProxies( List<Proxy> proxies );
358 
359     MavenExecutionRequest addProxy( Proxy proxy );
360 
361     // Servers
362     List<Server> getServers();
363 
364     MavenExecutionRequest setServers( List<Server> servers );
365 
366     MavenExecutionRequest addServer( Server server );
367 
368     // Mirrors
369     List<Mirror> getMirrors();
370 
371     MavenExecutionRequest setMirrors( List<Mirror> mirrors );
372 
373     MavenExecutionRequest addMirror( Mirror mirror );
374 
375     // Plugin groups
376     List<String> getPluginGroups();
377 
378     MavenExecutionRequest setPluginGroups( List<String> pluginGroups );
379 
380     MavenExecutionRequest addPluginGroup( String pluginGroup );
381 
382     MavenExecutionRequest addPluginGroups( List<String> pluginGroups );
383 
384     boolean isProjectPresent();
385 
386     MavenExecutionRequest setProjectPresent( boolean isProjectPresent );
387 
388     File getUserSettingsFile();
389 
390     MavenExecutionRequest setUserSettingsFile( File userSettingsFile );
391 
392     File getGlobalSettingsFile();
393 
394     MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile );
395 
396     MavenExecutionRequest addRemoteRepository( ArtifactRepository repository );
397 
398     MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository );
399 
400     /**
401      * Set a new list of remote repositories to use the execution request. This is necessary if you perform
402      * transformations on the remote repositories being used. For example if you replace existing repositories with
403      * mirrors then it's easier to just replace the whole list with a new list of transformed repositories.
404      *
405      * @param repositories
406      * @return This request, never {@code null}.
407      */
408     MavenExecutionRequest setRemoteRepositories( List<ArtifactRepository> repositories );
409 
410     List<ArtifactRepository> getRemoteRepositories();
411 
412     MavenExecutionRequest setPluginArtifactRepositories( List<ArtifactRepository> repositories );
413 
414     List<ArtifactRepository> getPluginArtifactRepositories();
415 
416     MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache );
417 
418     RepositoryCache getRepositoryCache();
419 
420     WorkspaceReader getWorkspaceReader();
421 
422     MavenExecutionRequest setWorkspaceReader( WorkspaceReader workspaceReader );
423 
424     File getUserToolchainsFile();
425 
426     MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile );
427 
428     /**
429      *
430      *
431      * @return the global toolchains file
432      * @since 3.3.0
433      */
434     File getGlobalToolchainsFile();
435 
436     /**
437      *
438      * @param globalToolchainsFile the global toolchains file
439      * @return this request
440      * @since 3.3.0
441      */
442     MavenExecutionRequest setGlobalToolchainsFile( File globalToolchainsFile );
443 
444     ExecutionListener getExecutionListener();
445 
446     MavenExecutionRequest setExecutionListener( ExecutionListener executionListener );
447 
448     ProjectBuildingRequest getProjectBuildingRequest();
449 
450     /**
451      * @since 3.1
452      */
453     boolean isUseLegacyLocalRepository();
454 
455     /**
456      * @since 3.1
457      */
458     MavenExecutionRequest setUseLegacyLocalRepository( boolean useLegacyLocalRepository );
459 
460     /**
461      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
462      * of the builder's id.
463      *
464      * @since 3.2.0
465      */
466     MavenExecutionRequest setBuilderId( String builderId );
467 
468     /**
469      * Controls the {@link org.apache.maven.lifecycle.internal.builder.Builder} used by Maven by specification
470      * of the builders id.
471      *
472      * @since 3.2.0
473      */
474     String getBuilderId();
475 
476     /**
477      *
478      * @param toolchains all toolchains grouped by type
479      * @return this request
480      * @since 3.3.0
481      */
482     MavenExecutionRequest setToolchains( Map<String, List<ToolchainModel>> toolchains );
483 
484     /**
485      *
486      * @return all toolchains grouped by type, never {@code null}
487      * @since 3.3.0
488      */
489     Map<String, List<ToolchainModel>> getToolchains();
490 
491     /**
492      * @since 3.3.0
493      */
494     void setMultiModuleProjectDirectory( File file );
495 
496     /**
497      * @since 3.3.0
498      */
499     File getMultiModuleProjectDirectory();
500 
501     /**
502      * @since 3.3.0
503      */
504     MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher );
505 
506     /**
507      * @since 3.3.0
508      */
509     EventSpyDispatcher getEventSpyDispatcher();
510 
511     /**
512      * @since 3.3.0
513      */
514     Map<String, Object> getData();
515 }