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