View Javadoc

1   package org.apache.maven.execution;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.artifact.repository.ArtifactRepository;
23  import org.apache.maven.monitor.event.EventDispatcher;
24  import org.apache.maven.monitor.event.EventMonitor;
25  import org.apache.maven.profiles.ProfileManager;
26  import org.apache.maven.project.DefaultProjectBuilderConfiguration;
27  import org.apache.maven.project.ProjectBuilderConfiguration;
28  import org.apache.maven.settings.Settings;
29  
30  import java.util.Date;
31  import java.util.List;
32  import java.util.Properties;
33  
34  /**
35   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
36   * @version $Id: DefaultMavenExecutionRequest.java 687388 2008-08-20 17:19:21Z dfabulich $
37   */
38  public class DefaultMavenExecutionRequest
39      implements MavenExecutionRequest
40  {
41      /**
42       * @todo [BP] is this required? This hands off to MavenSession, but could be passed through the handler.handle function (+ createSession).
43       */
44      private final ArtifactRepository localRepository;
45  
46      private final List goals;
47  
48      protected MavenSession session;
49  
50      private final EventDispatcher eventDispatcher;
51  
52      private final Settings settings;
53  
54      private final String baseDirectory;
55  
56      private boolean recursive = true;
57  
58      private boolean reactorActive;
59  
60      private String pomFilename;
61  
62      private String failureBehavior;
63  
64      private final ProfileManager globalProfileManager;
65  
66      private final Properties executionProperties;
67  
68      private final Properties userProperties;
69  
70      private final Date startTime;
71  
72      private final boolean showErrors;
73      
74      private String makeBehavior;
75      
76      private String resumeFrom;
77      
78      private List selectedProjects;
79  
80      public DefaultMavenExecutionRequest( ArtifactRepository localRepository, Settings settings,
81                                           EventDispatcher eventDispatcher, List goals, String baseDirectory,
82                                           ProfileManager globalProfileManager, Properties executionProperties,
83                                           Properties userProperties,
84                                           boolean showErrors )
85      {
86          this.localRepository = localRepository;
87  
88          this.settings = settings;
89  
90          this.goals = goals;
91  
92          this.eventDispatcher = eventDispatcher;
93  
94          this.baseDirectory = baseDirectory;
95  
96          this.globalProfileManager = globalProfileManager;
97  
98          this.executionProperties = executionProperties;
99  
100         this.userProperties = userProperties;
101 
102         startTime = new Date();
103 
104         this.showErrors = showErrors;
105     }
106 
107     public Settings getSettings()
108     {
109         return settings;
110     }
111 
112     public String getBaseDirectory()
113     {
114         return baseDirectory;
115     }
116 
117     public boolean isRecursive()
118     {
119         return recursive;
120     }
121 
122     public void setRecursive( boolean recursive )
123     {
124         this.recursive = false;
125     }
126 
127     public ArtifactRepository getLocalRepository()
128     {
129         return localRepository;
130     }
131 
132     public List getGoals()
133     {
134         return goals;
135     }
136 
137     public Properties getExecutionProperties()
138     {
139         return executionProperties;
140     }
141 
142     // ----------------------------------------------------------------------
143     // Putting the session here but it can probably be folded right in here.
144     // ----------------------------------------------------------------------
145 
146     public MavenSession getSession()
147     {
148         return session;
149     }
150 
151     public void setSession( MavenSession session )
152     {
153         session = session;
154     }
155 
156     public void addEventMonitor( EventMonitor monitor )
157     {
158         eventDispatcher.addEventMonitor( monitor );
159     }
160 
161     public EventDispatcher getEventDispatcher()
162     {
163         return eventDispatcher;
164     }
165 
166     public void setReactorActive( boolean reactorActive )
167     {
168         this.reactorActive = reactorActive;
169     }
170 
171     public boolean isReactorActive()
172     {
173         return reactorActive;
174     }
175 
176     public void setPomFile( String pomFilename )
177     {
178         this.pomFilename = pomFilename;
179     }
180 
181     public String getPomFile()
182     {
183         return pomFilename;
184     }
185 
186     public void setFailureBehavior( String failureBehavior )
187     {
188         this.failureBehavior = failureBehavior;
189     }
190 
191     public String getFailureBehavior()
192     {
193         return failureBehavior;
194     }
195 
196     public ProfileManager getGlobalProfileManager()
197     {
198         return globalProfileManager;
199     }
200 
201     public Date getStartTime()
202     {
203         return startTime;
204     }
205 
206     public boolean isShowErrors()
207     {
208         return showErrors;
209     }
210 
211     public Properties getUserProperties()
212     {
213         return userProperties;
214     }
215 
216     public ProjectBuilderConfiguration getProjectBuilderConfiguration()
217     {
218         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
219         config.setLocalRepository( getLocalRepository() )
220               .setGlobalProfileManager( getGlobalProfileManager() )
221               .setExecutionProperties( getExecutionProperties() )
222               .setUserProperties( getUserProperties() )
223               .setBuildStartTime( startTime );
224 
225         return config;
226     }
227     
228     public String getMakeBehavior()
229     {
230         return makeBehavior;
231     }
232 
233     public void setMakeBehavior( String makeBehavior )
234     {
235         this.makeBehavior = makeBehavior;
236     }
237 
238     public String getResumeFrom()
239     {
240         return resumeFrom;
241     }
242 
243     public void setResumeFrom( String resumeFrom )
244     {
245         this.resumeFrom = resumeFrom;
246     }
247 
248     public List getSelectedProjects()
249     {
250         return selectedProjects;
251     }
252 
253     public void setSelectedProjects( List selectedProjects )
254     {
255         this.selectedProjects = selectedProjects;
256     }
257 
258 }