1 // =================== DO NOT EDIT THIS FILE ====================
2 // Generated by Modello Velocity from model.vm
3 // template, any modifications will be overwritten.
4 // ==============================================================
5 package org.apache.maven.api.model;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.Collections;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14 import org.apache.maven.api.annotations.Experimental;
15 import org.apache.maven.api.annotations.Generated;
16 import org.apache.maven.api.annotations.Immutable;
17 import org.apache.maven.api.annotations.Nonnull;
18 import org.apache.maven.api.annotations.NotThreadSafe;
19 import org.apache.maven.api.annotations.ThreadSafe;
20
21 /**
22 * Build configuration in a profile.
23 */
24 @Experimental
25 @Generated @ThreadSafe @Immutable
26 public class BuildBase
27 extends PluginConfiguration
28 implements Serializable, InputLocationTracker
29 {
30 /**
31 * The default goal (or phase in Maven 2) to execute when none is specified for
32 * the project. Note that in case of a multi-module build, only the default goal of the top-level
33 * project is relevant, i.e. the default goals of child modules are ignored. Since Maven 3,
34 * multiple goals/phases can be separated by whitespace.
35 */
36 final String defaultGoal;
37 /**
38 * This element describes all of the classpath resources such as properties
39 * files associated with a project. These resources are often included in the final
40 * package.
41 * The default value is {@code src/main/resources}.
42 */
43 final List<Resource> resources;
44 /**
45 * This element describes all of the classpath resources such as properties
46 * files associated with a project's unit tests.
47 * The default value is {@code src/test/resources}.
48 */
49 final List<Resource> testResources;
50 /**
51 * The directory where all files generated by the build are placed.
52 * The default value is {@code target}.
53 */
54 final String directory;
55 /**
56 * The filename (excluding the extension, and with no path information) that
57 * the produced artifact will be called.
58 * The default value is {@code ${artifactId}-${version}}.
59 */
60 final String finalName;
61 /**
62 * The list of filter properties files that are used when filtering is enabled.
63 */
64 final List<String> filters;
65
66 /**
67 * Constructor for this class, package protected.
68 * @see Builder#build()
69 */
70 BuildBase(
71 Collection<Plugin> plugins,
72 PluginManagement pluginManagement,
73 String defaultGoal,
74 Collection<Resource> resources,
75 Collection<Resource> testResources,
76 String directory,
77 String finalName,
78 Collection<String> filters,
79 Map<Object, InputLocation> locations
80 ) {
81 super(
82 plugins,
83 pluginManagement,
84 locations
85 );
86 this.defaultGoal = defaultGoal;
87 this.resources = ImmutableCollections.copy(resources);
88 this.testResources = ImmutableCollections.copy(testResources);
89 this.directory = directory;
90 this.finalName = finalName;
91 this.filters = ImmutableCollections.copy(filters);
92 }
93
94 /**
95 * The default goal (or phase in Maven 2) to execute when none is specified for
96 * the project. Note that in case of a multi-module build, only the default goal of the top-level
97 * project is relevant, i.e. the default goals of child modules are ignored. Since Maven 3,
98 * multiple goals/phases can be separated by whitespace.
99 *
100 * @return a {@code String}
101 */
102 public String getDefaultGoal() {
103 return this.defaultGoal;
104 }
105
106 /**
107 * This element describes all of the classpath resources such as properties
108 * files associated with a project. These resources are often included in the final
109 * package.
110 * The default value is {@code src/main/resources}.
111 *
112 * @return a {@code List<Resource>}
113 */
114 @Nonnull
115 public List<Resource> getResources() {
116 return this.resources;
117 }
118
119 /**
120 * This element describes all of the classpath resources such as properties
121 * files associated with a project's unit tests.
122 * The default value is {@code src/test/resources}.
123 *
124 * @return a {@code List<Resource>}
125 */
126 @Nonnull
127 public List<Resource> getTestResources() {
128 return this.testResources;
129 }
130
131 /**
132 * The directory where all files generated by the build are placed.
133 * The default value is {@code target}.
134 *
135 * @return a {@code String}
136 */
137 public String getDirectory() {
138 return this.directory;
139 }
140
141 /**
142 * The filename (excluding the extension, and with no path information) that
143 * the produced artifact will be called.
144 * The default value is {@code ${artifactId}-${version}}.
145 *
146 * @return a {@code String}
147 */
148 public String getFinalName() {
149 return this.finalName;
150 }
151
152 /**
153 * The list of filter properties files that are used when filtering is enabled.
154 *
155 * @return a {@code List<String>}
156 */
157 @Nonnull
158 public List<String> getFilters() {
159 return this.filters;
160 }
161
162 /**
163 * Creates a new builder with this object as the basis.
164 *
165 * @return a {@code Builder}
166 */
167 @Nonnull
168 public Builder with() {
169 return newBuilder(this);
170 }
171 /**
172 * Creates a new {@code BuildBase} instance using the specified plugins.
173 *
174 * @param plugins the new {@code Collection<Plugin>} to use
175 * @return a {@code BuildBase} with the specified plugins
176 */
177 @Nonnull
178 public BuildBase withPlugins(Collection<Plugin> plugins) {
179 return newBuilder(this, true).plugins(plugins).build();
180 }
181 /**
182 * Creates a new {@code BuildBase} instance using the specified pluginManagement.
183 *
184 * @param pluginManagement the new {@code PluginManagement} to use
185 * @return a {@code BuildBase} with the specified pluginManagement
186 */
187 @Nonnull
188 public BuildBase withPluginManagement(PluginManagement pluginManagement) {
189 return newBuilder(this, true).pluginManagement(pluginManagement).build();
190 }
191 /**
192 * Creates a new {@code BuildBase} instance using the specified defaultGoal.
193 *
194 * @param defaultGoal the new {@code String} to use
195 * @return a {@code BuildBase} with the specified defaultGoal
196 */
197 @Nonnull
198 public BuildBase withDefaultGoal(String defaultGoal) {
199 return newBuilder(this, true).defaultGoal(defaultGoal).build();
200 }
201 /**
202 * Creates a new {@code BuildBase} instance using the specified resources.
203 *
204 * @param resources the new {@code Collection<Resource>} to use
205 * @return a {@code BuildBase} with the specified resources
206 */
207 @Nonnull
208 public BuildBase withResources(Collection<Resource> resources) {
209 return newBuilder(this, true).resources(resources).build();
210 }
211 /**
212 * Creates a new {@code BuildBase} instance using the specified testResources.
213 *
214 * @param testResources the new {@code Collection<Resource>} to use
215 * @return a {@code BuildBase} with the specified testResources
216 */
217 @Nonnull
218 public BuildBase withTestResources(Collection<Resource> testResources) {
219 return newBuilder(this, true).testResources(testResources).build();
220 }
221 /**
222 * Creates a new {@code BuildBase} instance using the specified directory.
223 *
224 * @param directory the new {@code String} to use
225 * @return a {@code BuildBase} with the specified directory
226 */
227 @Nonnull
228 public BuildBase withDirectory(String directory) {
229 return newBuilder(this, true).directory(directory).build();
230 }
231 /**
232 * Creates a new {@code BuildBase} instance using the specified finalName.
233 *
234 * @param finalName the new {@code String} to use
235 * @return a {@code BuildBase} with the specified finalName
236 */
237 @Nonnull
238 public BuildBase withFinalName(String finalName) {
239 return newBuilder(this, true).finalName(finalName).build();
240 }
241 /**
242 * Creates a new {@code BuildBase} instance using the specified filters.
243 *
244 * @param filters the new {@code Collection<String>} to use
245 * @return a {@code BuildBase} with the specified filters
246 */
247 @Nonnull
248 public BuildBase withFilters(Collection<String> filters) {
249 return newBuilder(this, true).filters(filters).build();
250 }
251
252 /**
253 * Creates a new {@code BuildBase} instance.
254 * Equivalent to {@code newInstance(true)}.
255 * @see #newInstance(boolean)
256 *
257 * @return a new {@code BuildBase}
258 */
259 @Nonnull
260 public static BuildBase newInstance() {
261 return newInstance(true);
262 }
263
264 /**
265 * Creates a new {@code BuildBase} instance using default values or not.
266 * Equivalent to {@code newBuilder(withDefaults).build()}.
267 *
268 * @param withDefaults the boolean indicating whether default values should be used
269 * @return a new {@code BuildBase}
270 */
271 @Nonnull
272 public static BuildBase newInstance(boolean withDefaults) {
273 return newBuilder(withDefaults).build();
274 }
275
276 /**
277 * Creates a new {@code BuildBase} builder instance.
278 * Equivalent to {@code newBuilder(true)}.
279 * @see #newBuilder(boolean)
280 *
281 * @return a new {@code Builder}
282 */
283 @Nonnull
284 public static Builder newBuilder() {
285 return newBuilder(true);
286 }
287
288 /**
289 * Creates a new {@code BuildBase} builder instance using default values or not.
290 *
291 * @param withDefaults the boolean indicating whether default values should be used
292 * @return a new {@code Builder}
293 */
294 @Nonnull
295 public static Builder newBuilder(boolean withDefaults) {
296 return new Builder(withDefaults);
297 }
298
299 /**
300 * Creates a new {@code BuildBase} builder instance using the specified object as a basis.
301 * Equivalent to {@code newBuilder(from, false)}.
302 *
303 * @param from the {@code BuildBase} instance to use as a basis
304 * @return a new {@code Builder}
305 */
306 @Nonnull
307 public static Builder newBuilder(BuildBase from) {
308 return newBuilder(from, false);
309 }
310
311 /**
312 * Creates a new {@code BuildBase} builder instance using the specified object as a basis.
313 *
314 * @param from the {@code BuildBase} instance to use as a basis
315 * @param forceCopy the boolean indicating if a copy should be forced
316 * @return a new {@code Builder}
317 */
318 @Nonnull
319 public static Builder newBuilder(BuildBase from, boolean forceCopy) {
320 return new Builder(from, forceCopy);
321 }
322
323 /**
324 * Builder class used to create BuildBase instances.
325 * @see #with()
326 * @see #newBuilder()
327 */
328 @NotThreadSafe
329 public static class Builder
330 extends PluginConfiguration.Builder
331 {
332 BuildBase base;
333 String defaultGoal;
334 Collection<Resource> resources;
335 Collection<Resource> testResources;
336 String directory;
337 String finalName;
338 Collection<String> filters;
339
340 Builder(boolean withDefaults) {
341 super(withDefaults);
342 if (withDefaults) {
343 }
344 }
345
346 Builder(BuildBase base, boolean forceCopy) {
347 super(base, forceCopy);
348 if (forceCopy) {
349 this.defaultGoal = base.defaultGoal;
350 this.resources = base.resources;
351 this.testResources = base.testResources;
352 this.directory = base.directory;
353 this.finalName = base.finalName;
354 this.filters = base.filters;
355 this.locations = base.locations;
356 } else {
357 this.base = base;
358 }
359 }
360
361 @Nonnull
362 public Builder plugins(Collection<Plugin> plugins) {
363 this.plugins = plugins;
364 return this;
365 }
366
367 @Nonnull
368 public Builder pluginManagement(PluginManagement pluginManagement) {
369 this.pluginManagement = pluginManagement;
370 return this;
371 }
372
373 @Nonnull
374 public Builder defaultGoal(String defaultGoal) {
375 this.defaultGoal = defaultGoal;
376 return this;
377 }
378
379 @Nonnull
380 public Builder resources(Collection<Resource> resources) {
381 this.resources = resources;
382 return this;
383 }
384
385 @Nonnull
386 public Builder testResources(Collection<Resource> testResources) {
387 this.testResources = testResources;
388 return this;
389 }
390
391 @Nonnull
392 public Builder directory(String directory) {
393 this.directory = directory;
394 return this;
395 }
396
397 @Nonnull
398 public Builder finalName(String finalName) {
399 this.finalName = finalName;
400 return this;
401 }
402
403 @Nonnull
404 public Builder filters(Collection<String> filters) {
405 this.filters = filters;
406 return this;
407 }
408
409
410 @Nonnull
411 public Builder location(Object key, InputLocation location) {
412 if (location != null) {
413 if (!(this.locations instanceof HashMap)) {
414 this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
415 }
416 this.locations.put(key, location);
417 }
418 return this;
419 }
420
421 @Nonnull
422 public BuildBase build() {
423 if (base != null
424 && (plugins == null || plugins == base.plugins)
425 && (pluginManagement == null || pluginManagement == base.pluginManagement)
426 && (defaultGoal == null || defaultGoal == base.defaultGoal)
427 && (resources == null || resources == base.resources)
428 && (testResources == null || testResources == base.testResources)
429 && (directory == null || directory == base.directory)
430 && (finalName == null || finalName == base.finalName)
431 && (filters == null || filters == base.filters)
432 ) {
433 return base;
434 }
435 Map<Object, InputLocation> locations = null;
436 InputLocation location = null;
437 InputLocation pluginsLocation = null;
438 InputLocation pluginManagementLocation = null;
439 InputLocation defaultGoalLocation = null;
440 InputLocation resourcesLocation = null;
441 InputLocation testResourcesLocation = null;
442 InputLocation directoryLocation = null;
443 InputLocation finalNameLocation = null;
444 InputLocation filtersLocation = null;
445 if (this.locations != null) {
446 locations = this.locations;
447 }
448 return new BuildBase(
449 plugins != null ? plugins : (base != null ? base.plugins : null),
450 pluginManagement != null ? pluginManagement : (base != null ? base.pluginManagement : null),
451 defaultGoal != null ? defaultGoal : (base != null ? base.defaultGoal : null),
452 resources != null ? resources : (base != null ? base.resources : null),
453 testResources != null ? testResources : (base != null ? base.testResources : null),
454 directory != null ? directory : (base != null ? base.directory : null),
455 finalName != null ? finalName : (base != null ? base.finalName : null),
456 filters != null ? filters : (base != null ? base.filters : null),
457 locations != null ? locations : (base != null ? base.locations : null)
458 );
459 }
460 }
461
462
463
464 /**
465 * @see java.lang.Object#toString()
466 */
467 public String toString()
468 {
469 return "BuildBase {" + super.toString() + "}";
470 }
471
472
473 }