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 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      /** Location of the xml element for the field defaultGoal. */
66      final InputLocation defaultGoalLocation;
67      /** Location of the xml element for the field resources. */
68      final InputLocation resourcesLocation;
69      /** Location of the xml element for the field testResources. */
70      final InputLocation testResourcesLocation;
71      /** Location of the xml element for the field directory. */
72      final InputLocation directoryLocation;
73      /** Location of the xml element for the field finalName. */
74      final InputLocation finalNameLocation;
75      /** Location of the xml element for the field filters. */
76      final InputLocation filtersLocation;
77  
78      /**
79        * Constructor for this class, package protected.
80        * @see Builder#build()
81        */
82      BuildBase(
83          Collection<Plugin> plugins,
84          PluginManagement pluginManagement,
85          String defaultGoal,
86          Collection<Resource> resources,
87          Collection<Resource> testResources,
88          String directory,
89          String finalName,
90          Collection<String> filters,
91          Map<Object, InputLocation> locations,
92          InputLocation location,
93          InputLocation pluginsLocation,
94          InputLocation pluginManagementLocation,
95          InputLocation defaultGoalLocation,
96          InputLocation resourcesLocation,
97          InputLocation testResourcesLocation,
98          InputLocation directoryLocation,
99          InputLocation finalNameLocation,
100         InputLocation filtersLocation
101     )
102     {
103         super(
104             plugins,
105             pluginManagement,
106             locations,
107             location,
108             pluginsLocation,
109             pluginManagementLocation
110         );
111         this.defaultGoal = defaultGoal;
112         this.resources = ImmutableCollections.copy( resources );
113         this.testResources = ImmutableCollections.copy( testResources );
114         this.directory = directory;
115         this.finalName = finalName;
116         this.filters = ImmutableCollections.copy( filters );
117         this.defaultGoalLocation = defaultGoalLocation;
118         this.resourcesLocation = resourcesLocation;
119         this.testResourcesLocation = testResourcesLocation;
120         this.directoryLocation = directoryLocation;
121         this.finalNameLocation = finalNameLocation;
122         this.filtersLocation = filtersLocation;
123     }
124 
125     /**
126      * The default goal (or phase in Maven 2) to execute when none is specified for
127      * the project. Note that in case of a multi-module build, only the default goal of the top-level
128      * project is relevant, i.e. the default goals of child modules are ignored. Since Maven 3,
129      * multiple goals/phases can be separated by whitespace.
130      *
131      * @return a {@code String}
132      */
133     public String getDefaultGoal()
134     {
135         return this.defaultGoal;
136     }
137 
138     /**
139      * This element describes all of the classpath resources such as properties
140      * files associated with a project. These resources are often included in the final
141      * package.
142      * The default value is {@code src/main/resources}.
143      *
144      * @return a {@code List<Resource>}
145      */
146     @Nonnull
147     public List<Resource> getResources()
148     {
149         return this.resources;
150     }
151 
152     /**
153      * This element describes all of the classpath resources such as properties
154      * files associated with a project's unit tests.
155      * The default value is {@code src/test/resources}.
156      *
157      * @return a {@code List<Resource>}
158      */
159     @Nonnull
160     public List<Resource> getTestResources()
161     {
162         return this.testResources;
163     }
164 
165     /**
166      * The directory where all files generated by the build are placed.
167      * The default value is {@code target}.
168      *
169      * @return a {@code String}
170      */
171     public String getDirectory()
172     {
173         return this.directory;
174     }
175 
176     /**
177      * The filename (excluding the extension, and with no path information) that
178      * the produced artifact will be called.
179      * The default value is {@code ${artifactId}-${version}}.
180      *
181      * @return a {@code String}
182      */
183     public String getFinalName()
184     {
185         return this.finalName;
186     }
187 
188     /**
189      * The list of filter properties files that are used when filtering is enabled.
190      *
191      * @return a {@code List<String>}
192      */
193     @Nonnull
194     public List<String> getFilters()
195     {
196         return this.filters;
197     }
198 
199     /**
200      * Gets the location of the specified field in the input source.
201      */
202     public InputLocation getLocation( Object key )
203     {
204         if ( key instanceof String )
205         {
206             switch ( ( String ) key )
207             {
208                 case "defaultGoal":
209                     return defaultGoalLocation;
210                 case "resources":
211                     return resourcesLocation;
212                 case "testResources":
213                     return testResourcesLocation;
214                 case "directory":
215                     return directoryLocation;
216                 case "finalName":
217                     return finalNameLocation;
218                 case "filters":
219                     return filtersLocation;
220             }
221         }
222         return super.getLocation( key );
223     }
224 
225     /**
226      * Creates a new builder with this object as the basis.
227      *
228      * @return a {@code Builder}
229      */
230     @Nonnull
231     public Builder with()
232     {
233         return newBuilder( this );
234     }
235     /**
236      * Creates a new {@code BuildBase} instance using the specified plugins.
237      *
238      * @param plugins the new {@code Collection<Plugin>} to use
239      * @return a {@code BuildBase} with the specified plugins
240      */
241     @Nonnull
242     public BuildBase withPlugins( Collection<Plugin> plugins )
243     {
244         return with().plugins( plugins ).build();
245     }
246     /**
247      * Creates a new {@code BuildBase} instance using the specified pluginManagement.
248      *
249      * @param pluginManagement the new {@code PluginManagement} to use
250      * @return a {@code BuildBase} with the specified pluginManagement
251      */
252     @Nonnull
253     public BuildBase withPluginManagement( PluginManagement pluginManagement )
254     {
255         return with().pluginManagement( pluginManagement ).build();
256     }
257     /**
258      * Creates a new {@code BuildBase} instance using the specified defaultGoal.
259      *
260      * @param defaultGoal the new {@code String} to use
261      * @return a {@code BuildBase} with the specified defaultGoal
262      */
263     @Nonnull
264     public BuildBase withDefaultGoal( String defaultGoal )
265     {
266         return with().defaultGoal( defaultGoal ).build();
267     }
268     /**
269      * Creates a new {@code BuildBase} instance using the specified resources.
270      *
271      * @param resources the new {@code Collection<Resource>} to use
272      * @return a {@code BuildBase} with the specified resources
273      */
274     @Nonnull
275     public BuildBase withResources( Collection<Resource> resources )
276     {
277         return with().resources( resources ).build();
278     }
279     /**
280      * Creates a new {@code BuildBase} instance using the specified testResources.
281      *
282      * @param testResources the new {@code Collection<Resource>} to use
283      * @return a {@code BuildBase} with the specified testResources
284      */
285     @Nonnull
286     public BuildBase withTestResources( Collection<Resource> testResources )
287     {
288         return with().testResources( testResources ).build();
289     }
290     /**
291      * Creates a new {@code BuildBase} instance using the specified directory.
292      *
293      * @param directory the new {@code String} to use
294      * @return a {@code BuildBase} with the specified directory
295      */
296     @Nonnull
297     public BuildBase withDirectory( String directory )
298     {
299         return with().directory( directory ).build();
300     }
301     /**
302      * Creates a new {@code BuildBase} instance using the specified finalName.
303      *
304      * @param finalName the new {@code String} to use
305      * @return a {@code BuildBase} with the specified finalName
306      */
307     @Nonnull
308     public BuildBase withFinalName( String finalName )
309     {
310         return with().finalName( finalName ).build();
311     }
312     /**
313      * Creates a new {@code BuildBase} instance using the specified filters.
314      *
315      * @param filters the new {@code Collection<String>} to use
316      * @return a {@code BuildBase} with the specified filters
317      */
318     @Nonnull
319     public BuildBase withFilters( Collection<String> filters )
320     {
321         return with().filters( filters ).build();
322     }
323 
324     /**
325      * Creates a new {@code BuildBase} instance.
326      * Equivalent to {@code newInstance( true )}.
327      * @see #newInstance(boolean)
328      *
329      * @return a new {@code BuildBase}
330      */
331     @Nonnull
332     public static BuildBase newInstance()
333     {
334         return newInstance( true );
335     }
336 
337     /**
338      * Creates a new {@code BuildBase} instance using default values or not.
339      * Equivalent to {@code newBuilder( withDefaults ).build()}.
340      *
341      * @param withDefaults the boolean indicating whether default values should be used
342      * @return a new {@code BuildBase}
343      */
344     @Nonnull
345     public static BuildBase newInstance( boolean withDefaults )
346     {
347         return newBuilder( withDefaults ).build();
348     }
349 
350     /**
351      * Creates a new {@code BuildBase} builder instance.
352      * Equivalent to {@code newBuilder( true )}.
353      * @see #newBuilder(boolean)
354      *
355      * @return a new {@code Builder}
356      */
357     @Nonnull
358     public static Builder newBuilder()
359     {
360         return newBuilder( true );
361     }
362 
363     /**
364      * Creates a new {@code BuildBase} builder instance using default values or not.
365      *
366      * @param withDefaults the boolean indicating whether default values should be used
367      * @return a new {@code Builder}
368      */
369     @Nonnull
370     public static Builder newBuilder( boolean withDefaults )
371     {
372         return new Builder( withDefaults );
373     }
374 
375     /**
376      * Creates a new {@code BuildBase} builder instance using the specified object as a basis.
377      * Equivalent to {@code newBuilder( from, false )}.
378      *
379      * @param from the {@code BuildBase} instance to use as a basis
380      * @return a new {@code Builder}
381      */
382     @Nonnull
383     public static Builder newBuilder( BuildBase from )
384     {
385         return newBuilder( from, false );
386     }
387 
388     /**
389      * Creates a new {@code BuildBase} builder instance using the specified object as a basis.
390      *
391      * @param from the {@code BuildBase} instance to use as a basis
392      * @param forceCopy the boolean indicating if a copy should be forced
393      * @return a new {@code Builder}
394      */
395     @Nonnull
396     public static Builder newBuilder( BuildBase from, boolean forceCopy )
397     {
398         return new Builder( from, forceCopy );
399     }
400 
401     /**
402      * Builder class used to create BuildBase instances.
403      * @see #with()
404      * @see #newBuilder()
405      */
406     @NotThreadSafe
407     public static class Builder
408         extends PluginConfiguration.Builder
409     {
410         BuildBase base;
411         String defaultGoal;
412         Collection<Resource> resources;
413         Collection<Resource> testResources;
414         String directory;
415         String finalName;
416         Collection<String> filters;
417 
418         Builder( boolean withDefaults )
419         {
420             super( withDefaults );
421             if ( withDefaults )
422             {
423             }
424         }
425 
426         Builder( BuildBase base, boolean forceCopy )
427         {
428             super( base, forceCopy );
429             if ( forceCopy )
430             {
431                 this.defaultGoal = base.defaultGoal;
432                 this.resources = base.resources;
433                 this.testResources = base.testResources;
434                 this.directory = base.directory;
435                 this.finalName = base.finalName;
436                 this.filters = base.filters;
437             }
438             else
439             {
440                 this.base = base;
441             }
442         }
443 
444         @Nonnull
445         public Builder plugins( Collection<Plugin> plugins )
446         {
447             this.plugins = plugins;
448             return this;
449         }
450 
451         @Nonnull
452         public Builder pluginManagement( PluginManagement pluginManagement )
453         {
454             this.pluginManagement = pluginManagement;
455             return this;
456         }
457 
458         @Nonnull
459         public Builder defaultGoal( String defaultGoal )
460         {
461             this.defaultGoal = defaultGoal;
462             return this;
463         }
464 
465         @Nonnull
466         public Builder resources( Collection<Resource> resources )
467         {
468             this.resources = resources;
469             return this;
470         }
471 
472         @Nonnull
473         public Builder testResources( Collection<Resource> testResources )
474         {
475             this.testResources = testResources;
476             return this;
477         }
478 
479         @Nonnull
480         public Builder directory( String directory )
481         {
482             this.directory = directory;
483             return this;
484         }
485 
486         @Nonnull
487         public Builder finalName( String finalName )
488         {
489             this.finalName = finalName;
490             return this;
491         }
492 
493         @Nonnull
494         public Builder filters( Collection<String> filters )
495         {
496             this.filters = filters;
497             return this;
498         }
499 
500 
501         @Nonnull
502         public Builder location( Object key, InputLocation location )
503         {
504             if ( location != null )
505             {
506                 if ( this.locations == null )
507                 {
508                     this.locations = new HashMap<>();
509                 }
510                 this.locations.put( key, location );
511             }
512             return this;
513         }
514 
515         @Nonnull
516         public BuildBase build()
517         {
518             if ( base != null
519                     && ( plugins == null || plugins == base.plugins )
520                     && ( pluginManagement == null || pluginManagement == base.pluginManagement )
521                     && ( defaultGoal == null || defaultGoal == base.defaultGoal )
522                     && ( resources == null || resources == base.resources )
523                     && ( testResources == null || testResources == base.testResources )
524                     && ( directory == null || directory == base.directory )
525                     && ( finalName == null || finalName == base.finalName )
526                     && ( filters == null || filters == base.filters )
527             )
528             {
529                 return base;
530             }
531             Map<Object, InputLocation> locations = null;
532             InputLocation location = null;
533             InputLocation pluginsLocation = null;
534             InputLocation pluginManagementLocation = null;
535             InputLocation defaultGoalLocation = null;
536             InputLocation resourcesLocation = null;
537             InputLocation testResourcesLocation = null;
538             InputLocation directoryLocation = null;
539             InputLocation finalNameLocation = null;
540             InputLocation filtersLocation = null;
541             if ( this.locations != null )
542             {
543                 locations = this.locations;
544                 location = locations.remove( "" );
545                 pluginsLocation = locations.remove( "plugins" );
546                 pluginManagementLocation = locations.remove( "pluginManagement" );
547                 defaultGoalLocation = locations.remove( "defaultGoal" );
548                 resourcesLocation = locations.remove( "resources" );
549                 testResourcesLocation = locations.remove( "testResources" );
550                 directoryLocation = locations.remove( "directory" );
551                 finalNameLocation = locations.remove( "finalName" );
552                 filtersLocation = locations.remove( "filters" );
553             }
554             return new BuildBase(
555                 plugins != null ? plugins : ( base != null ? base.plugins : null ),
556                 pluginManagement != null ? pluginManagement : ( base != null ? base.pluginManagement : null ),
557                 defaultGoal != null ? defaultGoal : ( base != null ? base.defaultGoal : null ),
558                 resources != null ? resources : ( base != null ? base.resources : null ),
559                 testResources != null ? testResources : ( base != null ? base.testResources : null ),
560                 directory != null ? directory : ( base != null ? base.directory : null ),
561                 finalName != null ? finalName : ( base != null ? base.finalName : null ),
562                 filters != null ? filters : ( base != null ? base.filters : null ),
563                 locations != null ? locations : ( base != null ? base.locations : null ),
564                 location != null ? location : ( base != null ? base.location : null ),
565                 pluginsLocation != null ? pluginsLocation : ( base != null ? base.pluginsLocation : null ),
566                 pluginManagementLocation != null ? pluginManagementLocation : ( base != null ? base.pluginManagementLocation : null ),
567                 defaultGoalLocation != null ? defaultGoalLocation : ( base != null ? base.defaultGoalLocation : null ),
568                 resourcesLocation != null ? resourcesLocation : ( base != null ? base.resourcesLocation : null ),
569                 testResourcesLocation != null ? testResourcesLocation : ( base != null ? base.testResourcesLocation : null ),
570                 directoryLocation != null ? directoryLocation : ( base != null ? base.directoryLocation : null ),
571                 finalNameLocation != null ? finalNameLocation : ( base != null ? base.finalNameLocation : null ),
572                 filtersLocation != null ? filtersLocation : ( base != null ? base.filtersLocation : null )
573             );
574         }
575     }
576 
577 
578             
579     /**
580      * @see java.lang.Object#toString()
581      */
582     public String toString()
583     {
584         return "BuildBase {" + super.toString() + "}";
585     }
586             
587           
588 }