1
2
3
4 package org.apache.maven.api.model;
5
6 import java.io.Serializable;
7 import java.util.ArrayList;
8 import java.util.Collection;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.List;
12 import java.util.Map;
13 import org.apache.maven.api.annotations.Experimental;
14 import org.apache.maven.api.annotations.Generated;
15 import org.apache.maven.api.annotations.Immutable;
16 import org.apache.maven.api.annotations.Nonnull;
17 import org.apache.maven.api.annotations.NotThreadSafe;
18 import org.apache.maven.api.annotations.ThreadSafe;
19
20
21
22
23 @Experimental
24 @Generated @ThreadSafe @Immutable
25 public class BuildBase
26 extends PluginConfiguration
27 implements Serializable, InputLocationTracker
28 {
29
30
31
32
33
34
35 final String defaultGoal;
36
37
38
39
40
41
42 final List<Resource> resources;
43
44
45
46
47
48 final List<Resource> testResources;
49
50
51
52
53 final String directory;
54
55
56
57
58
59 final String finalName;
60
61
62
63 final List<String> filters;
64
65 final InputLocation defaultGoalLocation;
66
67 final InputLocation resourcesLocation;
68
69 final InputLocation testResourcesLocation;
70
71 final InputLocation directoryLocation;
72
73 final InputLocation finalNameLocation;
74
75 final InputLocation filtersLocation;
76
77
78
79
80
81 BuildBase(
82 Collection<Plugin> plugins,
83 PluginManagement pluginManagement,
84 String defaultGoal,
85 Collection<Resource> resources,
86 Collection<Resource> testResources,
87 String directory,
88 String finalName,
89 Collection<String> filters,
90 Map<Object, InputLocation> locations,
91 InputLocation location,
92 InputLocation pluginsLocation,
93 InputLocation pluginManagementLocation,
94 InputLocation defaultGoalLocation,
95 InputLocation resourcesLocation,
96 InputLocation testResourcesLocation,
97 InputLocation directoryLocation,
98 InputLocation finalNameLocation,
99 InputLocation filtersLocation
100 )
101 {
102 super(
103 plugins,
104 pluginManagement,
105 locations,
106 location,
107 pluginsLocation,
108 pluginManagementLocation
109 );
110 this.defaultGoal = defaultGoal;
111 this.resources = ImmutableCollections.copy( resources );
112 this.testResources = ImmutableCollections.copy( testResources );
113 this.directory = directory;
114 this.finalName = finalName;
115 this.filters = ImmutableCollections.copy( filters );
116 this.defaultGoalLocation = defaultGoalLocation;
117 this.resourcesLocation = resourcesLocation;
118 this.testResourcesLocation = testResourcesLocation;
119 this.directoryLocation = directoryLocation;
120 this.finalNameLocation = finalNameLocation;
121 this.filtersLocation = filtersLocation;
122 }
123
124
125
126
127
128
129
130
131
132 public String getDefaultGoal()
133 {
134 return this.defaultGoal;
135 }
136
137
138
139
140
141
142
143
144
145 @Nonnull
146 public List<Resource> getResources()
147 {
148 return this.resources;
149 }
150
151
152
153
154
155
156
157
158 @Nonnull
159 public List<Resource> getTestResources()
160 {
161 return this.testResources;
162 }
163
164
165
166
167
168
169
170 public String getDirectory()
171 {
172 return this.directory;
173 }
174
175
176
177
178
179
180
181
182 public String getFinalName()
183 {
184 return this.finalName;
185 }
186
187
188
189
190
191
192 @Nonnull
193 public List<String> getFilters()
194 {
195 return this.filters;
196 }
197
198
199
200
201 public InputLocation getLocation( Object key )
202 {
203 if ( key instanceof String )
204 {
205 switch ( ( String ) key )
206 {
207 case "defaultGoal":
208 return defaultGoalLocation;
209 case "resources":
210 return resourcesLocation;
211 case "testResources":
212 return testResourcesLocation;
213 case "directory":
214 return directoryLocation;
215 case "finalName":
216 return finalNameLocation;
217 case "filters":
218 return filtersLocation;
219 }
220 }
221 return super.getLocation( key );
222 }
223
224
225
226
227
228
229 @Nonnull
230 public Builder with()
231 {
232 return newBuilder( this );
233 }
234
235
236
237
238
239
240 @Nonnull
241 public BuildBase withPlugins( Collection<Plugin> plugins )
242 {
243 return with().plugins( plugins ).build();
244 }
245
246
247
248
249
250
251 @Nonnull
252 public BuildBase withPluginManagement( PluginManagement pluginManagement )
253 {
254 return with().pluginManagement( pluginManagement ).build();
255 }
256
257
258
259
260
261
262 @Nonnull
263 public BuildBase withDefaultGoal( String defaultGoal )
264 {
265 return with().defaultGoal( defaultGoal ).build();
266 }
267
268
269
270
271
272
273 @Nonnull
274 public BuildBase withResources( Collection<Resource> resources )
275 {
276 return with().resources( resources ).build();
277 }
278
279
280
281
282
283
284 @Nonnull
285 public BuildBase withTestResources( Collection<Resource> testResources )
286 {
287 return with().testResources( testResources ).build();
288 }
289
290
291
292
293
294
295 @Nonnull
296 public BuildBase withDirectory( String directory )
297 {
298 return with().directory( directory ).build();
299 }
300
301
302
303
304
305
306 @Nonnull
307 public BuildBase withFinalName( String finalName )
308 {
309 return with().finalName( finalName ).build();
310 }
311
312
313
314
315
316
317 @Nonnull
318 public BuildBase withFilters( Collection<String> filters )
319 {
320 return with().filters( filters ).build();
321 }
322
323
324
325
326
327
328
329
330 @Nonnull
331 public static BuildBase newInstance()
332 {
333 return newInstance( true );
334 }
335
336
337
338
339
340
341
342
343 @Nonnull
344 public static BuildBase newInstance( boolean withDefaults )
345 {
346 return newBuilder( withDefaults ).build();
347 }
348
349
350
351
352
353
354
355
356 @Nonnull
357 public static Builder newBuilder()
358 {
359 return newBuilder( true );
360 }
361
362
363
364
365
366
367
368 @Nonnull
369 public static Builder newBuilder( boolean withDefaults )
370 {
371 return new Builder( withDefaults );
372 }
373
374
375
376
377
378
379
380
381 @Nonnull
382 public static Builder newBuilder( BuildBase from )
383 {
384 return newBuilder( from, false );
385 }
386
387
388
389
390
391
392
393
394 @Nonnull
395 public static Builder newBuilder( BuildBase from, boolean forceCopy )
396 {
397 return new Builder( from, forceCopy );
398 }
399
400
401
402
403
404
405 @NotThreadSafe
406 public static class Builder
407 extends PluginConfiguration.Builder
408 {
409 BuildBase base;
410 String defaultGoal;
411 Collection<Resource> resources;
412 Collection<Resource> testResources;
413 String directory;
414 String finalName;
415 Collection<String> filters;
416
417 Builder( boolean withDefaults )
418 {
419 super( withDefaults );
420 if ( withDefaults )
421 {
422 }
423 }
424
425 Builder( BuildBase base, boolean forceCopy )
426 {
427 super( base, forceCopy );
428 if ( forceCopy )
429 {
430 this.defaultGoal = base.defaultGoal;
431 this.resources = base.resources;
432 this.testResources = base.testResources;
433 this.directory = base.directory;
434 this.finalName = base.finalName;
435 this.filters = base.filters;
436 }
437 else
438 {
439 this.base = base;
440 }
441 }
442
443 @Nonnull
444 public Builder plugins( Collection<Plugin> plugins )
445 {
446 this.plugins = plugins;
447 return this;
448 }
449
450 @Nonnull
451 public Builder pluginManagement( PluginManagement pluginManagement )
452 {
453 this.pluginManagement = pluginManagement;
454 return this;
455 }
456
457 @Nonnull
458 public Builder defaultGoal( String defaultGoal )
459 {
460 this.defaultGoal = defaultGoal;
461 return this;
462 }
463
464 @Nonnull
465 public Builder resources( Collection<Resource> resources )
466 {
467 this.resources = resources;
468 return this;
469 }
470
471 @Nonnull
472 public Builder testResources( Collection<Resource> testResources )
473 {
474 this.testResources = testResources;
475 return this;
476 }
477
478 @Nonnull
479 public Builder directory( String directory )
480 {
481 this.directory = directory;
482 return this;
483 }
484
485 @Nonnull
486 public Builder finalName( String finalName )
487 {
488 this.finalName = finalName;
489 return this;
490 }
491
492 @Nonnull
493 public Builder filters( Collection<String> filters )
494 {
495 this.filters = filters;
496 return this;
497 }
498
499
500 @Nonnull
501 public Builder location( Object key, InputLocation location )
502 {
503 if ( location != null )
504 {
505 if ( this.locations == null )
506 {
507 this.locations = new HashMap<>();
508 }
509 this.locations.put( key, location );
510 }
511 return this;
512 }
513
514 @Nonnull
515 public BuildBase build()
516 {
517 if ( base != null
518 && ( plugins == null || plugins == base.plugins )
519 && ( pluginManagement == null || pluginManagement == base.pluginManagement )
520 && ( defaultGoal == null || defaultGoal == base.defaultGoal )
521 && ( resources == null || resources == base.resources )
522 && ( testResources == null || testResources == base.testResources )
523 && ( directory == null || directory == base.directory )
524 && ( finalName == null || finalName == base.finalName )
525 && ( filters == null || filters == base.filters )
526 )
527 {
528 return base;
529 }
530 Map<Object, InputLocation> locations = null;
531 InputLocation location = null;
532 InputLocation pluginsLocation = null;
533 InputLocation pluginManagementLocation = null;
534 InputLocation defaultGoalLocation = null;
535 InputLocation resourcesLocation = null;
536 InputLocation testResourcesLocation = null;
537 InputLocation directoryLocation = null;
538 InputLocation finalNameLocation = null;
539 InputLocation filtersLocation = null;
540 if ( this.locations != null )
541 {
542 locations = this.locations;
543 location = locations.remove( "" );
544 pluginsLocation = locations.remove( "plugins" );
545 pluginManagementLocation = locations.remove( "pluginManagement" );
546 defaultGoalLocation = locations.remove( "defaultGoal" );
547 resourcesLocation = locations.remove( "resources" );
548 testResourcesLocation = locations.remove( "testResources" );
549 directoryLocation = locations.remove( "directory" );
550 finalNameLocation = locations.remove( "finalName" );
551 filtersLocation = locations.remove( "filters" );
552 }
553 return new BuildBase(
554 plugins != null ? plugins : ( base != null ? base.plugins : null ),
555 pluginManagement != null ? pluginManagement : ( base != null ? base.pluginManagement : null ),
556 defaultGoal != null ? defaultGoal : ( base != null ? base.defaultGoal : null ),
557 resources != null ? resources : ( base != null ? base.resources : null ),
558 testResources != null ? testResources : ( base != null ? base.testResources : null ),
559 directory != null ? directory : ( base != null ? base.directory : null ),
560 finalName != null ? finalName : ( base != null ? base.finalName : null ),
561 filters != null ? filters : ( base != null ? base.filters : null ),
562 locations != null ? locations : ( base != null ? base.locations : null ),
563 location != null ? location : ( base != null ? base.location : null ),
564 pluginsLocation != null ? pluginsLocation : ( base != null ? base.pluginsLocation : null ),
565 pluginManagementLocation != null ? pluginManagementLocation : ( base != null ? base.pluginManagementLocation : null ),
566 defaultGoalLocation != null ? defaultGoalLocation : ( base != null ? base.defaultGoalLocation : null ),
567 resourcesLocation != null ? resourcesLocation : ( base != null ? base.resourcesLocation : null ),
568 testResourcesLocation != null ? testResourcesLocation : ( base != null ? base.testResourcesLocation : null ),
569 directoryLocation != null ? directoryLocation : ( base != null ? base.directoryLocation : null ),
570 finalNameLocation != null ? finalNameLocation : ( base != null ? base.finalNameLocation : null ),
571 filtersLocation != null ? filtersLocation : ( base != null ? base.filtersLocation : null )
572 );
573 }
574 }
575
576 }