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.ArrayList;
24  import java.util.Date;
25  import java.util.HashMap;
26  import java.util.List;
27  import java.util.Map;
28  import java.util.Objects;
29  import java.util.Properties;
30  
31  import org.apache.maven.artifact.repository.ArtifactRepository;
32  import org.apache.maven.eventspy.internal.EventSpyDispatcher;
33  import org.apache.maven.model.Profile;
34  import org.apache.maven.project.DefaultProjectBuildingRequest;
35  import org.apache.maven.project.ProjectBuildingRequest;
36  import org.apache.maven.properties.internal.SystemProperties;
37  import org.apache.maven.settings.Mirror;
38  import org.apache.maven.settings.Proxy;
39  import org.apache.maven.settings.Server;
40  import org.apache.maven.toolchain.model.ToolchainModel;
41  import org.eclipse.aether.DefaultRepositoryCache;
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 class DefaultMavenExecutionRequest
50      implements MavenExecutionRequest
51  {
52  
53      private RepositoryCache repositoryCache = new DefaultRepositoryCache();
54  
55      private WorkspaceReader workspaceReader;
56  
57      private ArtifactRepository localRepository;
58  
59      private EventSpyDispatcher eventSpyDispatcher;
60  
61      private File localRepositoryPath;
62  
63      private boolean offline = false;
64  
65      private boolean interactiveMode = true;
66  
67      private boolean cacheTransferError;
68  
69      private boolean cacheNotFound;
70  
71      private List<Proxy> proxies;
72  
73      private List<Server> servers;
74  
75      private List<Mirror> mirrors;
76  
77      private List<Profile> profiles;
78  
79      private List<String> pluginGroups;
80  
81      private boolean isProjectPresent = true;
82  
83      // ----------------------------------------------------------------------------
84      // We need to allow per execution user and global settings as the embedder
85      // might be running in a mode where its executing many threads with totally
86      // different settings.
87      // ----------------------------------------------------------------------------
88  
89      private File userSettingsFile;
90  
91      private File globalSettingsFile;
92  
93      private File userToolchainsFile;
94  
95      private File globalToolchainsFile;
96  
97      // ----------------------------------------------------------------------------
98      // Request
99      // ----------------------------------------------------------------------------
100 
101     private File multiModuleProjectDirectory;
102 
103     private File basedir;
104 
105     private List<String> goals;
106 
107     private boolean useReactor = false;
108 
109     private boolean recursive = true;
110 
111     private File pom;
112 
113     private String reactorFailureBehavior = REACTOR_FAIL_FAST;
114 
115     private List<String> selectedProjects;
116 
117     private List<String> excludedProjects;
118 
119     private String resumeFrom;
120 
121     private String makeBehavior;
122 
123     private Properties systemProperties;
124 
125     private Properties userProperties;
126 
127     private Date startTime;
128 
129     private boolean showErrors = false;
130 
131     private List<String> activeProfiles;
132 
133     private List<String> inactiveProfiles;
134 
135     private TransferListener transferListener;
136 
137     private int loggingLevel = LOGGING_LEVEL_INFO;
138 
139     private String globalChecksumPolicy;
140 
141     private boolean updateSnapshots = false;
142 
143     private List<ArtifactRepository> remoteRepositories;
144 
145     private List<ArtifactRepository> pluginArtifactRepositories;
146 
147     private ExecutionListener executionListener;
148 
149     private int degreeOfConcurrency = 1;
150 
151     private String builderId = "singlethreaded";
152 
153     private Map<String, List<ToolchainModel>> toolchains;
154 
155     /**
156      * Suppress SNAPSHOT updates.
157      *
158      * @issue MNG-2681
159      */
160     private boolean noSnapshotUpdates;
161 
162     private boolean useLegacyLocalRepositoryManager = false;
163 
164     private Map<String, Object> data;
165 
166     public DefaultMavenExecutionRequest()
167     {
168     }
169 
170     public static MavenExecutionRequest copy( MavenExecutionRequest original )
171     {
172         DefaultMavenExecutionRequest copy = new DefaultMavenExecutionRequest();
173         copy.setLocalRepository( original.getLocalRepository() );
174         copy.setLocalRepositoryPath( original.getLocalRepositoryPath() );
175         copy.setOffline( original.isOffline() );
176         copy.setInteractiveMode( original.isInteractiveMode() );
177         copy.setCacheNotFound( original.isCacheNotFound() );
178         copy.setCacheTransferError( original.isCacheTransferError() );
179         copy.setProxies( original.getProxies() );
180         copy.setServers( original.getServers() );
181         copy.setMirrors( original.getMirrors() );
182         copy.setProfiles( original.getProfiles() );
183         copy.setPluginGroups( original.getPluginGroups() );
184         copy.setProjectPresent( original.isProjectPresent() );
185         copy.setUserSettingsFile( original.getUserSettingsFile() );
186         copy.setGlobalSettingsFile( original.getGlobalSettingsFile() );
187         copy.setUserToolchainsFile( original.getUserToolchainsFile() );
188         copy.setGlobalToolchainsFile( original.getGlobalToolchainsFile() );
189         copy.setBaseDirectory( ( original.getBaseDirectory() != null ) ? new File( original.getBaseDirectory() )
190                                                                        : null );
191         copy.setGoals( original.getGoals() );
192         copy.setRecursive( original.isRecursive() );
193         copy.setPom( original.getPom() );
194         copy.setSystemProperties( original.getSystemProperties() );
195         copy.setUserProperties( original.getUserProperties() );
196         copy.setShowErrors( original.isShowErrors() );
197         copy.setActiveProfiles( original.getActiveProfiles() );
198         copy.setInactiveProfiles( original.getInactiveProfiles() );
199         copy.setTransferListener( original.getTransferListener() );
200         copy.setLoggingLevel( original.getLoggingLevel() );
201         copy.setGlobalChecksumPolicy( original.getGlobalChecksumPolicy() );
202         copy.setUpdateSnapshots( original.isUpdateSnapshots() );
203         copy.setRemoteRepositories( original.getRemoteRepositories() );
204         copy.setPluginArtifactRepositories( original.getPluginArtifactRepositories() );
205         copy.setRepositoryCache( original.getRepositoryCache() );
206         copy.setWorkspaceReader( original.getWorkspaceReader() );
207         copy.setNoSnapshotUpdates( original.isNoSnapshotUpdates() );
208         copy.setExecutionListener( original.getExecutionListener() );
209         copy.setUseLegacyLocalRepository( original.isUseLegacyLocalRepository() );
210         copy.setBuilderId( original.getBuilderId() );
211         return copy;
212     }
213 
214     @Override
215     public String getBaseDirectory()
216     {
217         if ( basedir == null )
218         {
219             return null;
220         }
221 
222         return basedir.getAbsolutePath();
223     }
224 
225     @Override
226     public ArtifactRepository getLocalRepository()
227     {
228         return localRepository;
229     }
230 
231     @Override
232     public File getLocalRepositoryPath()
233     {
234         return localRepositoryPath;
235     }
236 
237     @Override
238     public List<String> getGoals()
239     {
240         if ( goals == null )
241         {
242             goals = new ArrayList<>();
243         }
244         return goals;
245     }
246 
247     @Override
248     public Properties getSystemProperties()
249     {
250         if ( systemProperties == null )
251         {
252             systemProperties = new Properties();
253         }
254 
255         return systemProperties;
256     }
257 
258     @Override
259     public Properties getUserProperties()
260     {
261         if ( userProperties == null )
262         {
263             userProperties = new Properties();
264         }
265 
266         return userProperties;
267     }
268 
269     @Override
270     public File getPom()
271     {
272         return pom;
273     }
274 
275     @Override
276     public String getReactorFailureBehavior()
277     {
278         return reactorFailureBehavior;
279     }
280 
281     @Override
282     public List<String> getSelectedProjects()
283     {
284         if ( selectedProjects == null )
285         {
286             selectedProjects = new ArrayList<>();
287         }
288 
289         return selectedProjects;
290     }
291 
292     @Override
293     public List<String> getExcludedProjects()
294     {
295         if ( excludedProjects == null )
296         {
297             excludedProjects = new ArrayList<>();
298         }
299 
300         return excludedProjects;
301     }
302 
303     @Override
304     public String getResumeFrom()
305     {
306         return resumeFrom;
307     }
308 
309     @Override
310     public String getMakeBehavior()
311     {
312         return makeBehavior;
313     }
314 
315     @Override
316     public Date getStartTime()
317     {
318         return startTime;
319     }
320 
321     @Override
322     public boolean isShowErrors()
323     {
324         return showErrors;
325     }
326 
327     @Override
328     public boolean isInteractiveMode()
329     {
330         return interactiveMode;
331     }
332 
333     @Override
334     public MavenExecutionRequest setActiveProfiles( List<String> activeProfiles )
335     {
336         if ( activeProfiles != null )
337         {
338             this.activeProfiles = new ArrayList<>( activeProfiles );
339         }
340         else
341         {
342             this.activeProfiles = null;
343         }
344 
345         return this;
346     }
347 
348     @Override
349     public MavenExecutionRequest setInactiveProfiles( List<String> inactiveProfiles )
350     {
351         if ( inactiveProfiles != null )
352         {
353             this.inactiveProfiles = new ArrayList<>( inactiveProfiles );
354         }
355         else
356         {
357             this.inactiveProfiles = null;
358         }
359 
360         return this;
361     }
362 
363     @Override
364     public MavenExecutionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
365     {
366         if ( remoteRepositories != null )
367         {
368             this.remoteRepositories = new ArrayList<>( remoteRepositories );
369         }
370         else
371         {
372             this.remoteRepositories = null;
373         }
374 
375         return this;
376     }
377 
378     @Override
379     public MavenExecutionRequest setPluginArtifactRepositories( List<ArtifactRepository> pluginArtifactRepositories )
380     {
381         if ( pluginArtifactRepositories != null )
382         {
383             this.pluginArtifactRepositories = new ArrayList<>( pluginArtifactRepositories );
384         }
385         else
386         {
387             this.pluginArtifactRepositories = null;
388         }
389 
390         return this;
391     }
392 
393     public void setProjectBuildingConfiguration( ProjectBuildingRequest projectBuildingConfiguration )
394     {
395         this.projectBuildingRequest = projectBuildingConfiguration;
396     }
397 
398     @Override
399     public List<String> getActiveProfiles()
400     {
401         if ( activeProfiles == null )
402         {
403             activeProfiles = new ArrayList<>();
404         }
405         return activeProfiles;
406     }
407 
408     @Override
409     public List<String> getInactiveProfiles()
410     {
411         if ( inactiveProfiles == null )
412         {
413             inactiveProfiles = new ArrayList<>();
414         }
415         return inactiveProfiles;
416     }
417 
418     @Override
419     public TransferListener getTransferListener()
420     {
421         return transferListener;
422     }
423 
424     @Override
425     public int getLoggingLevel()
426     {
427         return loggingLevel;
428     }
429 
430     @Override
431     public boolean isOffline()
432     {
433         return offline;
434     }
435 
436     @Override
437     public boolean isUpdateSnapshots()
438     {
439         return updateSnapshots;
440     }
441 
442     @Override
443     public boolean isNoSnapshotUpdates()
444     {
445         return noSnapshotUpdates;
446     }
447 
448     @Override
449     public String getGlobalChecksumPolicy()
450     {
451         return globalChecksumPolicy;
452     }
453 
454     @Override
455     public boolean isRecursive()
456     {
457         return recursive;
458     }
459 
460     // ----------------------------------------------------------------------
461     //
462     // ----------------------------------------------------------------------
463 
464     @Override
465     public MavenExecutionRequest setBaseDirectory( File basedir )
466     {
467         this.basedir = basedir;
468 
469         return this;
470     }
471 
472     @Override
473     public MavenExecutionRequest setStartTime( Date startTime )
474     {
475         this.startTime = startTime;
476 
477         return this;
478     }
479 
480     @Override
481     public MavenExecutionRequest setShowErrors( boolean showErrors )
482     {
483         this.showErrors = showErrors;
484 
485         return this;
486     }
487 
488     @Override
489     public MavenExecutionRequest setGoals( List<String> goals )
490     {
491         if ( goals != null )
492         {
493             this.goals = new ArrayList<>( goals );
494         }
495         else
496         {
497             this.goals = null;
498         }
499 
500         return this;
501     }
502 
503     @Override
504     public MavenExecutionRequest setLocalRepository( ArtifactRepository localRepository )
505     {
506         this.localRepository = localRepository;
507 
508         if ( localRepository != null )
509         {
510             setLocalRepositoryPath( new File( localRepository.getBasedir() ).getAbsoluteFile() );
511         }
512 
513         return this;
514     }
515 
516     @Override
517     public MavenExecutionRequest setLocalRepositoryPath( File localRepository )
518     {
519         localRepositoryPath = localRepository;
520 
521         return this;
522     }
523 
524     @Override
525     public MavenExecutionRequest setLocalRepositoryPath( String localRepository )
526     {
527         localRepositoryPath = ( localRepository != null ) ? new File( localRepository ) : null;
528 
529         return this;
530     }
531 
532     @Override
533     public MavenExecutionRequest setSystemProperties( Properties properties )
534     {
535         if ( properties != null )
536         {
537             this.systemProperties = SystemProperties.copyProperties( properties );
538         }
539         else
540         {
541             this.systemProperties = null;
542         }
543 
544         return this;
545     }
546 
547     @Override
548     public MavenExecutionRequest setUserProperties( Properties userProperties )
549     {
550         if ( userProperties != null )
551         {
552             this.userProperties = new Properties();
553             this.userProperties.putAll( userProperties );
554         }
555         else
556         {
557             this.userProperties = null;
558         }
559 
560         return this;
561     }
562 
563     @Override
564     public MavenExecutionRequest setReactorFailureBehavior( String failureBehavior )
565     {
566         reactorFailureBehavior = failureBehavior;
567 
568         return this;
569     }
570 
571     @Override
572     public MavenExecutionRequest setSelectedProjects( List<String> selectedProjects )
573     {
574         if ( selectedProjects != null )
575         {
576             this.selectedProjects = new ArrayList<>( selectedProjects );
577         }
578         else
579         {
580             this.selectedProjects = null;
581         }
582 
583         return this;
584     }
585 
586     @Override
587     public MavenExecutionRequest setExcludedProjects( List<String> excludedProjects )
588     {
589         if ( excludedProjects != null )
590         {
591             this.excludedProjects = new ArrayList<>( excludedProjects );
592         }
593         else
594         {
595             this.excludedProjects = null;
596         }
597 
598         return this;
599     }
600 
601     @Override
602     public MavenExecutionRequest setResumeFrom( String project )
603     {
604         this.resumeFrom = project;
605 
606         return this;
607     }
608 
609     @Override
610     public MavenExecutionRequest setMakeBehavior( String makeBehavior )
611     {
612         this.makeBehavior = makeBehavior;
613 
614         return this;
615     }
616 
617     @Override
618     public MavenExecutionRequest addActiveProfile( String profile )
619     {
620         if ( !getActiveProfiles().contains( profile ) )
621         {
622             getActiveProfiles().add( profile );
623         }
624 
625         return this;
626     }
627 
628     @Override
629     public MavenExecutionRequest addInactiveProfile( String profile )
630     {
631         if ( !getInactiveProfiles().contains( profile ) )
632         {
633             getInactiveProfiles().add( profile );
634         }
635 
636         return this;
637     }
638 
639     @Override
640     public MavenExecutionRequest addActiveProfiles( List<String> profiles )
641     {
642         for ( String profile : profiles )
643         {
644             addActiveProfile( profile );
645         }
646 
647         return this;
648     }
649 
650     @Override
651     public MavenExecutionRequest addInactiveProfiles( List<String> profiles )
652     {
653         for ( String profile : profiles )
654         {
655             addInactiveProfile( profile );
656         }
657 
658         return this;
659     }
660 
661     public MavenExecutionRequest setUseReactor( boolean reactorActive )
662     {
663         useReactor = reactorActive;
664 
665         return this;
666     }
667 
668     public boolean useReactor()
669     {
670         return useReactor;
671     }
672 
673     /** @deprecated use {@link #setPom(File)} */
674     @Deprecated
675     public MavenExecutionRequest setPomFile( String pomFilename )
676     {
677         if ( pomFilename != null )
678         {
679             pom = new File( pomFilename );
680         }
681 
682         return this;
683     }
684 
685     @Override
686     public MavenExecutionRequest setPom( File pom )
687     {
688         this.pom = pom;
689 
690         return this;
691     }
692 
693     @Override
694     public MavenExecutionRequest setInteractiveMode( boolean interactive )
695     {
696         interactiveMode = interactive;
697 
698         return this;
699     }
700 
701     @Override
702     public MavenExecutionRequest setTransferListener( TransferListener transferListener )
703     {
704         this.transferListener = transferListener;
705 
706         return this;
707     }
708 
709     @Override
710     public MavenExecutionRequest setLoggingLevel( int loggingLevel )
711     {
712         this.loggingLevel = loggingLevel;
713 
714         return this;
715     }
716 
717     @Override
718     public MavenExecutionRequest setOffline( boolean offline )
719     {
720         this.offline = offline;
721 
722         return this;
723     }
724 
725     @Override
726     public MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots )
727     {
728         this.updateSnapshots = updateSnapshots;
729 
730         return this;
731     }
732 
733     @Override
734     public MavenExecutionRequest setNoSnapshotUpdates( boolean noSnapshotUpdates )
735     {
736         this.noSnapshotUpdates = noSnapshotUpdates;
737 
738         return this;
739     }
740 
741     @Override
742     public MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
743     {
744         this.globalChecksumPolicy = globalChecksumPolicy;
745 
746         return this;
747     }
748 
749     // ----------------------------------------------------------------------------
750     // Settings equivalents
751     // ----------------------------------------------------------------------------
752 
753     @Override
754     public List<Proxy> getProxies()
755     {
756         if ( proxies == null )
757         {
758             proxies = new ArrayList<>();
759         }
760         return proxies;
761     }
762 
763     @Override
764     public MavenExecutionRequest setProxies( List<Proxy> proxies )
765     {
766         if ( proxies != null )
767         {
768             this.proxies = new ArrayList<>( proxies );
769         }
770         else
771         {
772             this.proxies = null;
773         }
774 
775         return this;
776     }
777 
778     @Override
779     public MavenExecutionRequest addProxy( Proxy proxy )
780     {
781         Objects.requireNonNull( proxy, "proxy cannot be null" );
782 
783         for ( Proxy p : getProxies() )
784         {
785             if ( p.getId() != null && p.getId().equals( proxy.getId() ) )
786             {
787                 return this;
788             }
789         }
790 
791         getProxies().add( proxy );
792 
793         return this;
794     }
795 
796     @Override
797     public List<Server> getServers()
798     {
799         if ( servers == null )
800         {
801             servers = new ArrayList<>();
802         }
803         return servers;
804     }
805 
806     @Override
807     public MavenExecutionRequest setServers( List<Server> servers )
808     {
809         if ( servers != null )
810         {
811             this.servers = new ArrayList<>( servers );
812         }
813         else
814         {
815             this.servers = null;
816         }
817 
818         return this;
819     }
820 
821     @Override
822     public MavenExecutionRequest addServer( Server server )
823     {
824         Objects.requireNonNull( server, "server cannot be null" );
825 
826         for ( Server p : getServers() )
827         {
828             if ( p.getId() != null && p.getId().equals( server.getId() ) )
829             {
830                 return this;
831             }
832         }
833 
834         getServers().add( server );
835 
836         return this;
837     }
838 
839     @Override
840     public List<Mirror> getMirrors()
841     {
842         if ( mirrors == null )
843         {
844             mirrors = new ArrayList<>();
845         }
846         return mirrors;
847     }
848 
849     @Override
850     public MavenExecutionRequest setMirrors( List<Mirror> mirrors )
851     {
852         if ( mirrors != null )
853         {
854             this.mirrors = new ArrayList<>( mirrors );
855         }
856         else
857         {
858             this.mirrors = null;
859         }
860 
861         return this;
862     }
863 
864     @Override
865     public MavenExecutionRequest addMirror( Mirror mirror )
866     {
867         Objects.requireNonNull( mirror, "mirror cannot be null" );
868 
869         for ( Mirror p : getMirrors() )
870         {
871             if ( p.getId() != null && p.getId().equals( mirror.getId() ) )
872             {
873                 return this;
874             }
875         }
876 
877         getMirrors().add( mirror );
878 
879         return this;
880     }
881 
882     @Override
883     public List<Profile> getProfiles()
884     {
885         if ( profiles == null )
886         {
887             profiles = new ArrayList<>();
888         }
889         return profiles;
890     }
891 
892     @Override
893     public MavenExecutionRequest setProfiles( List<Profile> profiles )
894     {
895         if ( profiles != null )
896         {
897             this.profiles = new ArrayList<>( profiles );
898         }
899         else
900         {
901             this.profiles = null;
902         }
903 
904         return this;
905     }
906 
907     @Override
908     public List<String> getPluginGroups()
909     {
910         if ( pluginGroups == null )
911         {
912             pluginGroups = new ArrayList<>();
913         }
914 
915         return pluginGroups;
916     }
917 
918     @Override
919     public MavenExecutionRequest setPluginGroups( List<String> pluginGroups )
920     {
921         if ( pluginGroups != null )
922         {
923             this.pluginGroups = new ArrayList<>( pluginGroups );
924         }
925         else
926         {
927             this.pluginGroups = null;
928         }
929 
930         return this;
931     }
932 
933     @Override
934     public MavenExecutionRequest addPluginGroup( String pluginGroup )
935     {
936         if ( !getPluginGroups().contains( pluginGroup ) )
937         {
938             getPluginGroups().add( pluginGroup );
939         }
940 
941         return this;
942     }
943 
944     @Override
945     public MavenExecutionRequest addPluginGroups( List<String> pluginGroups )
946     {
947         for ( String pluginGroup : pluginGroups )
948         {
949             addPluginGroup( pluginGroup );
950         }
951 
952         return this;
953     }
954 
955     @Override
956     public MavenExecutionRequest setRecursive( boolean recursive )
957     {
958         this.recursive = recursive;
959 
960         return this;
961     }
962 
963     // calculated from request attributes.
964     private ProjectBuildingRequest projectBuildingRequest;
965 
966     @Override
967     public boolean isProjectPresent()
968     {
969         return isProjectPresent;
970     }
971 
972     @Override
973     public MavenExecutionRequest setProjectPresent( boolean projectPresent )
974     {
975         isProjectPresent = projectPresent;
976 
977         return this;
978     }
979 
980     // Settings files
981 
982     @Override
983     public File getUserSettingsFile()
984     {
985         return userSettingsFile;
986     }
987 
988     @Override
989     public MavenExecutionRequest setUserSettingsFile( File userSettingsFile )
990     {
991         this.userSettingsFile = userSettingsFile;
992 
993         return this;
994     }
995 
996     @Override
997     public File getGlobalSettingsFile()
998     {
999         return globalSettingsFile;
1000     }
1001 
1002     @Override
1003     public MavenExecutionRequest setGlobalSettingsFile( File globalSettingsFile )
1004     {
1005         this.globalSettingsFile = globalSettingsFile;
1006 
1007         return this;
1008     }
1009 
1010     @Override
1011     public File getUserToolchainsFile()
1012     {
1013         return userToolchainsFile;
1014     }
1015 
1016     @Override
1017     public MavenExecutionRequest setUserToolchainsFile( File userToolchainsFile )
1018     {
1019         this.userToolchainsFile = userToolchainsFile;
1020 
1021         return this;
1022     }
1023 
1024     @Override
1025     public File getGlobalToolchainsFile()
1026     {
1027         return globalToolchainsFile;
1028     }
1029 
1030     @Override
1031     public MavenExecutionRequest setGlobalToolchainsFile( File globalToolchainsFile )
1032     {
1033         this.globalToolchainsFile = globalToolchainsFile;
1034         return this;
1035     }
1036 
1037     @Override
1038     public MavenExecutionRequest addRemoteRepository( ArtifactRepository repository )
1039     {
1040         for ( ArtifactRepository repo : getRemoteRepositories() )
1041         {
1042             if ( repo.getId() != null && repo.getId().equals( repository.getId() ) )
1043             {
1044                 return this;
1045             }
1046         }
1047 
1048         getRemoteRepositories().add( repository );
1049 
1050         return this;
1051     }
1052 
1053     @Override
1054     public List<ArtifactRepository> getRemoteRepositories()
1055     {
1056         if ( remoteRepositories == null )
1057         {
1058             remoteRepositories = new ArrayList<>();
1059         }
1060         return remoteRepositories;
1061     }
1062 
1063     @Override
1064     public MavenExecutionRequest addPluginArtifactRepository( ArtifactRepository repository )
1065     {
1066         for ( ArtifactRepository repo : getPluginArtifactRepositories() )
1067         {
1068             if ( repo.getId() != null && repo.getId().equals( repository.getId() ) )
1069             {
1070                 return this;
1071             }
1072         }
1073 
1074         getPluginArtifactRepositories().add( repository );
1075 
1076         return this;
1077     }
1078 
1079     @Override
1080     public List<ArtifactRepository> getPluginArtifactRepositories()
1081     {
1082         if ( pluginArtifactRepositories == null )
1083         {
1084             pluginArtifactRepositories = new ArrayList<>();
1085         }
1086         return pluginArtifactRepositories;
1087     }
1088 
1089     // TODO this does not belong here.
1090     @Override
1091     public ProjectBuildingRequest getProjectBuildingRequest()
1092     {
1093         if ( projectBuildingRequest == null )
1094         {
1095             projectBuildingRequest = new DefaultProjectBuildingRequest();
1096             projectBuildingRequest.setLocalRepository( getLocalRepository() );
1097             projectBuildingRequest.setSystemProperties( getSystemProperties() );
1098             projectBuildingRequest.setUserProperties( getUserProperties() );
1099             projectBuildingRequest.setRemoteRepositories( getRemoteRepositories() );
1100             projectBuildingRequest.setPluginArtifactRepositories( getPluginArtifactRepositories() );
1101             projectBuildingRequest.setActiveProfileIds( getActiveProfiles() );
1102             projectBuildingRequest.setInactiveProfileIds( getInactiveProfiles() );
1103             projectBuildingRequest.setProfiles( getProfiles() );
1104             projectBuildingRequest.setProcessPlugins( true );
1105             projectBuildingRequest.setBuildStartTime( getStartTime() );
1106         }
1107 
1108         return projectBuildingRequest;
1109     }
1110 
1111     @Override
1112     public MavenExecutionRequest addProfile( Profile profile )
1113     {
1114         Objects.requireNonNull( profile, "profile cannot be null" );
1115 
1116         for ( Profile p : getProfiles() )
1117         {
1118             if ( p.getId() != null && p.getId().equals( profile.getId() ) )
1119             {
1120                 return this;
1121             }
1122         }
1123 
1124         getProfiles().add( profile );
1125 
1126         return this;
1127     }
1128 
1129     @Override
1130     public RepositoryCache getRepositoryCache()
1131     {
1132         return repositoryCache;
1133     }
1134 
1135     @Override
1136     public MavenExecutionRequest setRepositoryCache( RepositoryCache repositoryCache )
1137     {
1138         this.repositoryCache = repositoryCache;
1139 
1140         return this;
1141     }
1142 
1143     @Override
1144     public ExecutionListener getExecutionListener()
1145     {
1146         return executionListener;
1147     }
1148 
1149     @Override
1150     public MavenExecutionRequest setExecutionListener( ExecutionListener executionListener )
1151     {
1152         this.executionListener = executionListener;
1153 
1154         return this;
1155     }
1156 
1157     @Override
1158     public void setDegreeOfConcurrency( final int degreeOfConcurrency )
1159     {
1160         this.degreeOfConcurrency = degreeOfConcurrency;
1161     }
1162 
1163     @Override
1164     public int getDegreeOfConcurrency()
1165     {
1166         return degreeOfConcurrency;
1167     }
1168 
1169     @Override
1170     public WorkspaceReader getWorkspaceReader()
1171     {
1172         return workspaceReader;
1173     }
1174 
1175     @Override
1176     public MavenExecutionRequest setWorkspaceReader( WorkspaceReader workspaceReader )
1177     {
1178         this.workspaceReader = workspaceReader;
1179         return this;
1180     }
1181 
1182     @Override
1183     public boolean isCacheTransferError()
1184     {
1185         return cacheTransferError;
1186     }
1187 
1188     @Override
1189     public MavenExecutionRequest setCacheTransferError( boolean cacheTransferError )
1190     {
1191         this.cacheTransferError = cacheTransferError;
1192         return this;
1193     }
1194 
1195     @Override
1196     public boolean isCacheNotFound()
1197     {
1198         return cacheNotFound;
1199     }
1200 
1201     @Override
1202     public MavenExecutionRequest setCacheNotFound( boolean cacheNotFound )
1203     {
1204         this.cacheNotFound = cacheNotFound;
1205         return this;
1206     }
1207 
1208     @Override
1209     public boolean isUseLegacyLocalRepository()
1210     {
1211         return this.useLegacyLocalRepositoryManager;
1212     }
1213 
1214     @Override
1215     public MavenExecutionRequest setUseLegacyLocalRepository( boolean useLegacyLocalRepositoryManager )
1216     {
1217         this.useLegacyLocalRepositoryManager = useLegacyLocalRepositoryManager;
1218         return this;
1219     }
1220 
1221     @Override
1222     public MavenExecutionRequest setBuilderId( String builderId )
1223     {
1224         this.builderId = builderId;
1225         return this;
1226     }
1227 
1228     @Override
1229     public String getBuilderId()
1230     {
1231         return builderId;
1232     }
1233 
1234     @Override
1235     public Map<String, List<ToolchainModel>> getToolchains()
1236     {
1237         if ( toolchains == null )
1238         {
1239             toolchains = new HashMap<>();
1240         }
1241         return toolchains;
1242     }
1243 
1244     @Override
1245     public MavenExecutionRequest setToolchains( Map<String, List<ToolchainModel>> toolchains )
1246     {
1247         this.toolchains = toolchains;
1248         return this;
1249     }
1250 
1251     @Override
1252     public void setMultiModuleProjectDirectory( File directory )
1253     {
1254         this.multiModuleProjectDirectory = directory;
1255     }
1256 
1257     @Override
1258     public File getMultiModuleProjectDirectory()
1259     {
1260         return multiModuleProjectDirectory;
1261     }
1262 
1263     @Override
1264     public MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher )
1265     {
1266         this.eventSpyDispatcher = eventSpyDispatcher;
1267         return this;
1268     }
1269 
1270     @Override
1271     public EventSpyDispatcher getEventSpyDispatcher()
1272     {
1273         return eventSpyDispatcher;
1274     }
1275 
1276     @Override
1277     public Map<String, Object> getData()
1278     {
1279         if ( data == null )
1280         {
1281             data = new HashMap<>();
1282         }
1283 
1284         return data;
1285     }
1286 }