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