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