1 package org.apache.maven.project;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.Date;
24 import java.util.List;
25 import java.util.Properties;
26
27 import org.apache.maven.artifact.repository.ArtifactRepository;
28 import org.apache.maven.model.Profile;
29 import org.apache.maven.model.building.ModelBuildingRequest;
30 import org.eclipse.aether.RepositorySystemSession;
31
32 public class DefaultProjectBuildingRequest
33 implements ProjectBuildingRequest
34 {
35
36 private RepositorySystemSession repositorySession;
37
38 private ArtifactRepository localRepository;
39
40 private List<ArtifactRepository> remoteRepositories;
41
42 private List<ArtifactRepository> pluginArtifactRepositories;
43
44 private MavenProject project;
45
46 private int validationLevel = ModelBuildingRequest.VALIDATION_LEVEL_STRICT;
47
48 private boolean processPlugins;
49
50 private List<Profile> profiles;
51
52 private List<String> activeProfileIds;
53
54 private List<String> inactiveProfileIds;
55
56 private Properties systemProperties;
57
58 private Properties userProperties;
59
60 private Date buildStartTime;
61
62 private boolean resolveDependencies;
63
64 private boolean resolveVersionRanges;
65
66 private RepositoryMerging repositoryMerging = RepositoryMerging.POM_DOMINANT;
67
68 public DefaultProjectBuildingRequest()
69 {
70 processPlugins = true;
71 profiles = new ArrayList<Profile>();
72 activeProfileIds = new ArrayList<String>();
73 inactiveProfileIds = new ArrayList<String>();
74 systemProperties = new Properties();
75 userProperties = new Properties();
76 remoteRepositories = new ArrayList<ArtifactRepository>();
77 pluginArtifactRepositories = new ArrayList<ArtifactRepository>();
78 }
79
80 public DefaultProjectBuildingRequest( ProjectBuildingRequest request )
81 {
82 this();
83 setProcessPlugins( request.isProcessPlugins() );
84 setProfiles( request.getProfiles() );
85 setActiveProfileIds( request.getActiveProfileIds() );
86 setInactiveProfileIds( request.getInactiveProfileIds() );
87 setSystemProperties( request.getSystemProperties() );
88 setUserProperties( request.getUserProperties() );
89 setRemoteRepositories( request.getRemoteRepositories() );
90 setPluginArtifactRepositories( request.getPluginArtifactRepositories() );
91 setRepositorySession( request.getRepositorySession() );
92 setLocalRepository( request.getLocalRepository() );
93 setBuildStartTime( request.getBuildStartTime() );
94 setProject( request.getProject() );
95 setResolveDependencies( request.isResolveDependencies() );
96 setValidationLevel( request.getValidationLevel() );
97 }
98
99 public MavenProject getProject()
100 {
101 return project;
102 }
103
104 public void setProject( MavenProject mavenProject )
105 {
106 this.project = mavenProject;
107 }
108
109 public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository )
110 {
111 this.localRepository = localRepository;
112 return this;
113 }
114
115 public ArtifactRepository getLocalRepository()
116 {
117 return localRepository;
118 }
119
120 public List<ArtifactRepository> getRemoteRepositories()
121 {
122 return remoteRepositories;
123 }
124
125 public ProjectBuildingRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
126 {
127 if ( remoteRepositories != null )
128 {
129 this.remoteRepositories = new ArrayList<ArtifactRepository>( remoteRepositories );
130 }
131 else
132 {
133 this.remoteRepositories.clear();
134 }
135
136 return this;
137 }
138
139 public List<ArtifactRepository> getPluginArtifactRepositories()
140 {
141 return pluginArtifactRepositories;
142 }
143
144 public ProjectBuildingRequest setPluginArtifactRepositories( List<ArtifactRepository> pluginArtifactRepositories )
145 {
146 if ( pluginArtifactRepositories != null )
147 {
148 this.pluginArtifactRepositories = new ArrayList<ArtifactRepository>( pluginArtifactRepositories );
149 }
150 else
151 {
152 this.pluginArtifactRepositories.clear();
153 }
154
155 return this;
156 }
157
158 public Properties getSystemProperties()
159 {
160 return systemProperties;
161 }
162
163 public ProjectBuildingRequest setSystemProperties( Properties systemProperties )
164 {
165 if ( systemProperties != null )
166 {
167 this.systemProperties = new Properties();
168 this.systemProperties.putAll( systemProperties );
169 }
170 else
171 {
172 this.systemProperties.clear();
173 }
174
175 return this;
176 }
177
178 public Properties getUserProperties()
179 {
180 return userProperties;
181 }
182
183 public ProjectBuildingRequest setUserProperties( Properties userProperties )
184 {
185 if ( userProperties != null )
186 {
187 this.userProperties = new Properties();
188 this.userProperties.putAll( userProperties );
189 }
190 else
191 {
192 this.userProperties.clear();
193 }
194
195 return this;
196 }
197
198 public boolean isProcessPlugins()
199 {
200 return processPlugins;
201 }
202
203 public ProjectBuildingRequest setProcessPlugins( boolean processPlugins )
204 {
205 this.processPlugins = processPlugins;
206 return this;
207 }
208
209 public ProjectBuildingRequest setResolveDependencies( boolean resolveDependencies )
210 {
211 this.resolveDependencies = resolveDependencies;
212 return this;
213 }
214
215 public boolean isResolveDependencies()
216 {
217 return resolveDependencies;
218 }
219
220
221 public ProjectBuildingRequest setResolveVersionRanges( boolean value )
222 {
223 this.resolveVersionRanges = value;
224 return this;
225 }
226
227
228 public boolean isResolveVersionRanges()
229 {
230 return this.resolveVersionRanges;
231 }
232
233 public ProjectBuildingRequest setValidationLevel( int validationLevel )
234 {
235 this.validationLevel = validationLevel;
236 return this;
237 }
238
239 public int getValidationLevel()
240 {
241 return validationLevel;
242 }
243
244 public List<String> getActiveProfileIds()
245 {
246 return activeProfileIds;
247 }
248
249 public void setActiveProfileIds( List<String> activeProfileIds )
250 {
251 if ( activeProfileIds != null )
252 {
253 this.activeProfileIds = new ArrayList<String>( activeProfileIds );
254 }
255 else
256 {
257 this.activeProfileIds.clear();
258 }
259 }
260
261 public List<String> getInactiveProfileIds()
262 {
263 return inactiveProfileIds;
264 }
265
266 public void setInactiveProfileIds( List<String> inactiveProfileIds )
267 {
268 if ( inactiveProfileIds != null )
269 {
270 this.inactiveProfileIds = new ArrayList<String>( inactiveProfileIds );
271 }
272 else
273 {
274 this.inactiveProfileIds.clear();
275 }
276 }
277
278 public void setProfiles( List<Profile> profiles )
279 {
280 if ( profiles != null )
281 {
282 this.profiles = new ArrayList<Profile>( profiles );
283 }
284 else
285 {
286 this.profiles.clear();
287 }
288 }
289
290 public void addProfile( Profile profile )
291 {
292 profiles.add( profile );
293 }
294
295 public List<Profile> getProfiles()
296 {
297 return profiles;
298 }
299
300 public Date getBuildStartTime()
301 {
302 return buildStartTime;
303 }
304
305 public void setBuildStartTime( Date buildStartTime )
306 {
307 this.buildStartTime = buildStartTime;
308 }
309
310 public RepositorySystemSession getRepositorySession()
311 {
312 return repositorySession;
313 }
314
315 public DefaultProjectBuildingRequest setRepositorySession( RepositorySystemSession repositorySession )
316 {
317 this.repositorySession = repositorySession;
318 return this;
319 }
320
321 public DefaultProjectBuildingRequest setRepositoryMerging( RepositoryMerging repositoryMerging )
322 {
323 if ( repositoryMerging == null )
324 {
325 throw new IllegalArgumentException( "repository merge mode not specified" );
326 }
327 this.repositoryMerging = repositoryMerging;
328 return this;
329 }
330
331 public RepositoryMerging getRepositoryMerging()
332 {
333 return repositoryMerging;
334 }
335
336 }