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