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