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