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
24 @Experimental
25 @Generated @ThreadSafe @Immutable
26 public class Profile
27 extends ModelBase
28 implements Serializable, InputLocationTracker
29 {
30
31
32
33
34 final String id;
35
36
37
38
39 final Activation activation;
40
41
42
43 final BuildBase build;
44
45 final InputLocation idLocation;
46
47 final InputLocation activationLocation;
48
49 final InputLocation buildLocation;
50
51
52
53
54
55 Profile(
56 Collection<String> modules,
57 DistributionManagement distributionManagement,
58 Map<String, String> properties,
59 DependencyManagement dependencyManagement,
60 Collection<Dependency> dependencies,
61 Collection<Repository> repositories,
62 Collection<Repository> pluginRepositories,
63 Reporting reporting,
64 String id,
65 Activation activation,
66 BuildBase build,
67 Map<Object, InputLocation> locations,
68 InputLocation location,
69 InputLocation modulesLocation,
70 InputLocation distributionManagementLocation,
71 InputLocation propertiesLocation,
72 InputLocation dependencyManagementLocation,
73 InputLocation dependenciesLocation,
74 InputLocation repositoriesLocation,
75 InputLocation pluginRepositoriesLocation,
76 InputLocation reportingLocation,
77 InputLocation idLocation,
78 InputLocation activationLocation,
79 InputLocation buildLocation
80 )
81 {
82 super(
83 modules,
84 distributionManagement,
85 properties,
86 dependencyManagement,
87 dependencies,
88 repositories,
89 pluginRepositories,
90 reporting,
91 locations,
92 location,
93 modulesLocation,
94 distributionManagementLocation,
95 propertiesLocation,
96 dependencyManagementLocation,
97 dependenciesLocation,
98 repositoriesLocation,
99 pluginRepositoriesLocation,
100 reportingLocation
101 );
102 this.id = id;
103 this.activation = activation;
104 this.build = build;
105 this.idLocation = idLocation;
106 this.activationLocation = activationLocation;
107 this.buildLocation = buildLocation;
108 }
109
110
111
112
113
114
115
116 public String getId()
117 {
118 return this.id;
119 }
120
121
122
123
124
125
126
127 public Activation getActivation()
128 {
129 return this.activation;
130 }
131
132
133
134
135
136
137 public BuildBase getBuild()
138 {
139 return this.build;
140 }
141
142
143
144
145 public InputLocation getLocation( Object key )
146 {
147 if ( key instanceof String )
148 {
149 switch ( ( String ) key )
150 {
151 case "id":
152 return idLocation;
153 case "activation":
154 return activationLocation;
155 case "build":
156 return buildLocation;
157 }
158 }
159 return super.getLocation( key );
160 }
161
162
163
164
165
166
167 @Nonnull
168 public Builder with()
169 {
170 return newBuilder( this );
171 }
172
173
174
175
176
177
178 @Nonnull
179 public Profile withModules( Collection<String> modules )
180 {
181 return with().modules( modules ).build();
182 }
183
184
185
186
187
188
189 @Nonnull
190 public Profile withDistributionManagement( DistributionManagement distributionManagement )
191 {
192 return with().distributionManagement( distributionManagement ).build();
193 }
194
195
196
197
198
199
200 @Nonnull
201 public Profile withProperties( Map<String, String> properties )
202 {
203 return with().properties( properties ).build();
204 }
205
206
207
208
209
210
211 @Nonnull
212 public Profile withDependencyManagement( DependencyManagement dependencyManagement )
213 {
214 return with().dependencyManagement( dependencyManagement ).build();
215 }
216
217
218
219
220
221
222 @Nonnull
223 public Profile withDependencies( Collection<Dependency> dependencies )
224 {
225 return with().dependencies( dependencies ).build();
226 }
227
228
229
230
231
232
233 @Nonnull
234 public Profile withRepositories( Collection<Repository> repositories )
235 {
236 return with().repositories( repositories ).build();
237 }
238
239
240
241
242
243
244 @Nonnull
245 public Profile withPluginRepositories( Collection<Repository> pluginRepositories )
246 {
247 return with().pluginRepositories( pluginRepositories ).build();
248 }
249
250
251
252
253
254
255 @Nonnull
256 public Profile withReporting( Reporting reporting )
257 {
258 return with().reporting( reporting ).build();
259 }
260
261
262
263
264
265
266 @Nonnull
267 public Profile withId( String id )
268 {
269 return with().id( id ).build();
270 }
271
272
273
274
275
276
277 @Nonnull
278 public Profile withActivation( Activation activation )
279 {
280 return with().activation( activation ).build();
281 }
282
283
284
285
286
287
288 @Nonnull
289 public Profile withBuild( BuildBase build )
290 {
291 return with().build( build ).build();
292 }
293
294
295
296
297
298
299
300
301 @Nonnull
302 public static Profile newInstance()
303 {
304 return newInstance( true );
305 }
306
307
308
309
310
311
312
313
314 @Nonnull
315 public static Profile newInstance( boolean withDefaults )
316 {
317 return newBuilder( withDefaults ).build();
318 }
319
320
321
322
323
324
325
326
327 @Nonnull
328 public static Builder newBuilder()
329 {
330 return newBuilder( true );
331 }
332
333
334
335
336
337
338
339 @Nonnull
340 public static Builder newBuilder( boolean withDefaults )
341 {
342 return new Builder( withDefaults );
343 }
344
345
346
347
348
349
350
351
352 @Nonnull
353 public static Builder newBuilder( Profile from )
354 {
355 return newBuilder( from, false );
356 }
357
358
359
360
361
362
363
364
365 @Nonnull
366 public static Builder newBuilder( Profile from, boolean forceCopy )
367 {
368 return new Builder( from, forceCopy );
369 }
370
371
372
373
374
375
376 @NotThreadSafe
377 public static class Builder
378 extends ModelBase.Builder
379 {
380 Profile base;
381 String id;
382 Activation activation;
383 BuildBase build;
384
385 Builder( boolean withDefaults )
386 {
387 super( withDefaults );
388 if ( withDefaults )
389 {
390 this.id = "default";
391 }
392 }
393
394 Builder( Profile base, boolean forceCopy )
395 {
396 super( base, forceCopy );
397 if ( forceCopy )
398 {
399 this.id = base.id;
400 this.activation = base.activation;
401 this.build = base.build;
402 }
403 else
404 {
405 this.base = base;
406 }
407 }
408
409 @Nonnull
410 public Builder modules( Collection<String> modules )
411 {
412 this.modules = modules;
413 return this;
414 }
415
416 @Nonnull
417 public Builder distributionManagement( DistributionManagement distributionManagement )
418 {
419 this.distributionManagement = distributionManagement;
420 return this;
421 }
422
423 @Nonnull
424 public Builder properties( Map<String, String> properties )
425 {
426 this.properties = properties;
427 return this;
428 }
429
430 @Nonnull
431 public Builder dependencyManagement( DependencyManagement dependencyManagement )
432 {
433 this.dependencyManagement = dependencyManagement;
434 return this;
435 }
436
437 @Nonnull
438 public Builder dependencies( Collection<Dependency> dependencies )
439 {
440 this.dependencies = dependencies;
441 return this;
442 }
443
444 @Nonnull
445 public Builder repositories( Collection<Repository> repositories )
446 {
447 this.repositories = repositories;
448 return this;
449 }
450
451 @Nonnull
452 public Builder pluginRepositories( Collection<Repository> pluginRepositories )
453 {
454 this.pluginRepositories = pluginRepositories;
455 return this;
456 }
457
458 @Nonnull
459 public Builder reporting( Reporting reporting )
460 {
461 this.reporting = reporting;
462 return this;
463 }
464
465 @Nonnull
466 public Builder id( String id )
467 {
468 this.id = id;
469 return this;
470 }
471
472 @Nonnull
473 public Builder activation( Activation activation )
474 {
475 this.activation = activation;
476 return this;
477 }
478
479 @Nonnull
480 public Builder build( BuildBase build )
481 {
482 this.build = build;
483 return this;
484 }
485
486
487 @Nonnull
488 public Builder location( Object key, InputLocation location )
489 {
490 if ( location != null )
491 {
492 if ( this.locations == null )
493 {
494 this.locations = new HashMap<>();
495 }
496 this.locations.put( key, location );
497 }
498 return this;
499 }
500
501 @Nonnull
502 public Profile build()
503 {
504 if ( base != null
505 && ( modules == null || modules == base.modules )
506 && ( distributionManagement == null || distributionManagement == base.distributionManagement )
507 && ( properties == null || properties == base.properties )
508 && ( dependencyManagement == null || dependencyManagement == base.dependencyManagement )
509 && ( dependencies == null || dependencies == base.dependencies )
510 && ( repositories == null || repositories == base.repositories )
511 && ( pluginRepositories == null || pluginRepositories == base.pluginRepositories )
512 && ( reporting == null || reporting == base.reporting )
513 && ( id == null || id == base.id )
514 && ( activation == null || activation == base.activation )
515 && ( build == null || build == base.build )
516 )
517 {
518 return base;
519 }
520 Map<Object, InputLocation> locations = null;
521 InputLocation location = null;
522 InputLocation modulesLocation = null;
523 InputLocation distributionManagementLocation = null;
524 InputLocation propertiesLocation = null;
525 InputLocation dependencyManagementLocation = null;
526 InputLocation dependenciesLocation = null;
527 InputLocation repositoriesLocation = null;
528 InputLocation pluginRepositoriesLocation = null;
529 InputLocation reportingLocation = null;
530 InputLocation idLocation = null;
531 InputLocation activationLocation = null;
532 InputLocation buildLocation = null;
533 if ( this.locations != null )
534 {
535 locations = this.locations;
536 location = locations.remove( "" );
537 modulesLocation = locations.remove( "modules" );
538 distributionManagementLocation = locations.remove( "distributionManagement" );
539 propertiesLocation = locations.remove( "properties" );
540 dependencyManagementLocation = locations.remove( "dependencyManagement" );
541 dependenciesLocation = locations.remove( "dependencies" );
542 repositoriesLocation = locations.remove( "repositories" );
543 pluginRepositoriesLocation = locations.remove( "pluginRepositories" );
544 reportingLocation = locations.remove( "reporting" );
545 idLocation = locations.remove( "id" );
546 activationLocation = locations.remove( "activation" );
547 buildLocation = locations.remove( "build" );
548 }
549 return new Profile(
550 modules != null ? modules : ( base != null ? base.modules : null ),
551 distributionManagement != null ? distributionManagement : ( base != null ? base.distributionManagement : null ),
552 properties != null ? properties : ( base != null ? base.properties : null ),
553 dependencyManagement != null ? dependencyManagement : ( base != null ? base.dependencyManagement : null ),
554 dependencies != null ? dependencies : ( base != null ? base.dependencies : null ),
555 repositories != null ? repositories : ( base != null ? base.repositories : null ),
556 pluginRepositories != null ? pluginRepositories : ( base != null ? base.pluginRepositories : null ),
557 reporting != null ? reporting : ( base != null ? base.reporting : null ),
558 id != null ? id : ( base != null ? base.id : null ),
559 activation != null ? activation : ( base != null ? base.activation : null ),
560 build != null ? build : ( base != null ? base.build : null ),
561 locations != null ? locations : ( base != null ? base.locations : null ),
562 location != null ? location : ( base != null ? base.location : null ),
563 modulesLocation != null ? modulesLocation : ( base != null ? base.modulesLocation : null ),
564 distributionManagementLocation != null ? distributionManagementLocation : ( base != null ? base.distributionManagementLocation : null ),
565 propertiesLocation != null ? propertiesLocation : ( base != null ? base.propertiesLocation : null ),
566 dependencyManagementLocation != null ? dependencyManagementLocation : ( base != null ? base.dependencyManagementLocation : null ),
567 dependenciesLocation != null ? dependenciesLocation : ( base != null ? base.dependenciesLocation : null ),
568 repositoriesLocation != null ? repositoriesLocation : ( base != null ? base.repositoriesLocation : null ),
569 pluginRepositoriesLocation != null ? pluginRepositoriesLocation : ( base != null ? base.pluginRepositoriesLocation : null ),
570 reportingLocation != null ? reportingLocation : ( base != null ? base.reportingLocation : null ),
571 idLocation != null ? idLocation : ( base != null ? base.idLocation : null ),
572 activationLocation != null ? activationLocation : ( base != null ? base.activationLocation : null ),
573 buildLocation != null ? buildLocation : ( base != null ? base.buildLocation : null )
574 );
575 }
576 }
577
578
579
580 public static final String SOURCE_POM = "pom";
581
582 public static final String SOURCE_SETTINGS = "settings.xml";
583
584
585
586 private String source = SOURCE_POM;
587
588 public void setSource( String source )
589 {
590 this.source = source;
591 }
592
593 public String getSource()
594 {
595 return source;
596 }
597
598
599
600
601 public String toString()
602 {
603 return "Profile {id: " + getId() + ", source: " + getSource() + "}";
604 }
605
606
607 }