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