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