1
2
3
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
23
24 @Experimental
25 @Generated @ThreadSafe @Immutable
26 public class BuildBase
27 extends PluginConfiguration
28 implements Serializable, InputLocationTracker
29 {
30
31
32
33
34
35
36 final String defaultGoal;
37
38
39
40
41
42
43 final List<Resource> resources;
44
45
46
47
48
49 final List<Resource> testResources;
50
51
52
53
54 final String directory;
55
56
57
58
59
60 final String finalName;
61
62
63
64 final List<String> filters;
65
66 final InputLocation defaultGoalLocation;
67
68 final InputLocation resourcesLocation;
69
70 final InputLocation testResourcesLocation;
71
72 final InputLocation directoryLocation;
73
74 final InputLocation finalNameLocation;
75
76 final InputLocation filtersLocation;
77
78
79
80
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
127
128
129
130
131
132
133 public String getDefaultGoal()
134 {
135 return this.defaultGoal;
136 }
137
138
139
140
141
142
143
144
145
146 @Nonnull
147 public List<Resource> getResources()
148 {
149 return this.resources;
150 }
151
152
153
154
155
156
157
158
159 @Nonnull
160 public List<Resource> getTestResources()
161 {
162 return this.testResources;
163 }
164
165
166
167
168
169
170
171 public String getDirectory()
172 {
173 return this.directory;
174 }
175
176
177
178
179
180
181
182
183 public String getFinalName()
184 {
185 return this.finalName;
186 }
187
188
189
190
191
192
193 @Nonnull
194 public List<String> getFilters()
195 {
196 return this.filters;
197 }
198
199
200
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
227
228
229
230 @Nonnull
231 public Builder with()
232 {
233 return newBuilder( this );
234 }
235
236
237
238
239
240
241 @Nonnull
242 public BuildBase withPlugins( Collection<Plugin> plugins )
243 {
244 return with().plugins( plugins ).build();
245 }
246
247
248
249
250
251
252 @Nonnull
253 public BuildBase withPluginManagement( PluginManagement pluginManagement )
254 {
255 return with().pluginManagement( pluginManagement ).build();
256 }
257
258
259
260
261
262
263 @Nonnull
264 public BuildBase withDefaultGoal( String defaultGoal )
265 {
266 return with().defaultGoal( defaultGoal ).build();
267 }
268
269
270
271
272
273
274 @Nonnull
275 public BuildBase withResources( Collection<Resource> resources )
276 {
277 return with().resources( resources ).build();
278 }
279
280
281
282
283
284
285 @Nonnull
286 public BuildBase withTestResources( Collection<Resource> testResources )
287 {
288 return with().testResources( testResources ).build();
289 }
290
291
292
293
294
295
296 @Nonnull
297 public BuildBase withDirectory( String directory )
298 {
299 return with().directory( directory ).build();
300 }
301
302
303
304
305
306
307 @Nonnull
308 public BuildBase withFinalName( String finalName )
309 {
310 return with().finalName( finalName ).build();
311 }
312
313
314
315
316
317
318 @Nonnull
319 public BuildBase withFilters( Collection<String> filters )
320 {
321 return with().filters( filters ).build();
322 }
323
324
325
326
327
328
329
330
331 @Nonnull
332 public static BuildBase newInstance()
333 {
334 return newInstance( true );
335 }
336
337
338
339
340
341
342
343
344 @Nonnull
345 public static BuildBase newInstance( boolean withDefaults )
346 {
347 return newBuilder( withDefaults ).build();
348 }
349
350
351
352
353
354
355
356
357 @Nonnull
358 public static Builder newBuilder()
359 {
360 return newBuilder( true );
361 }
362
363
364
365
366
367
368
369 @Nonnull
370 public static Builder newBuilder( boolean withDefaults )
371 {
372 return new Builder( withDefaults );
373 }
374
375
376
377
378
379
380
381
382 @Nonnull
383 public static Builder newBuilder( BuildBase from )
384 {
385 return newBuilder( from, false );
386 }
387
388
389
390
391
392
393
394
395 @Nonnull
396 public static Builder newBuilder( BuildBase from, boolean forceCopy )
397 {
398 return new Builder( from, forceCopy );
399 }
400
401
402
403
404
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
581
582 public String toString()
583 {
584 return "BuildBase {" + super.toString() + "}";
585 }
586
587
588 }