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