1 package org.apache.maven.model.merge;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.LinkedHashMap;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Properties;
28
29 import org.apache.commons.lang3.Validate;
30 import org.apache.maven.model.Activation;
31 import org.apache.maven.model.Build;
32 import org.apache.maven.model.BuildBase;
33 import org.apache.maven.model.CiManagement;
34 import org.apache.maven.model.ConfigurationContainer;
35 import org.apache.maven.model.Contributor;
36 import org.apache.maven.model.Dependency;
37 import org.apache.maven.model.DependencyManagement;
38 import org.apache.maven.model.DeploymentRepository;
39 import org.apache.maven.model.Developer;
40 import org.apache.maven.model.DistributionManagement;
41 import org.apache.maven.model.Exclusion;
42 import org.apache.maven.model.Extension;
43 import org.apache.maven.model.FileSet;
44 import org.apache.maven.model.InputLocation;
45 import org.apache.maven.model.IssueManagement;
46 import org.apache.maven.model.License;
47 import org.apache.maven.model.MailingList;
48 import org.apache.maven.model.Model;
49 import org.apache.maven.model.ModelBase;
50 import org.apache.maven.model.Notifier;
51 import org.apache.maven.model.Organization;
52 import org.apache.maven.model.Parent;
53 import org.apache.maven.model.PatternSet;
54 import org.apache.maven.model.Plugin;
55 import org.apache.maven.model.PluginConfiguration;
56 import org.apache.maven.model.PluginContainer;
57 import org.apache.maven.model.PluginExecution;
58 import org.apache.maven.model.PluginManagement;
59 import org.apache.maven.model.Prerequisites;
60 import org.apache.maven.model.Profile;
61 import org.apache.maven.model.Relocation;
62 import org.apache.maven.model.ReportPlugin;
63 import org.apache.maven.model.ReportSet;
64 import org.apache.maven.model.Reporting;
65 import org.apache.maven.model.Repository;
66 import org.apache.maven.model.RepositoryBase;
67 import org.apache.maven.model.RepositoryPolicy;
68 import org.apache.maven.model.Resource;
69 import org.apache.maven.model.Scm;
70 import org.apache.maven.model.Site;
71 import org.codehaus.plexus.util.xml.Xpp3Dom;
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 @SuppressWarnings( { "checkstyle:methodname" } )
91 public class ModelMerger
92 {
93
94
95
96
97
98
99
100
101
102
103
104
105
106 public void merge( Model target, Model source, boolean sourceDominant, Map<?, ?> hints )
107 {
108 Validate.notNull( target, "target cannot be null" );
109
110 if ( source == null )
111 {
112 return;
113 }
114
115 Map<Object, Object> context = new HashMap<>();
116 if ( hints != null )
117 {
118 context.putAll( hints );
119 }
120
121 mergeModel( target, source, sourceDominant, context );
122 }
123
124 protected void mergeModel( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
125 {
126 mergeModelBase( target, source, sourceDominant, context );
127
128 mergeModel_ModelVersion( target, source, sourceDominant, context );
129 mergeModel_Parent( target, source, sourceDominant, context );
130 mergeModel_GroupId( target, source, sourceDominant, context );
131 mergeModel_ArtifactId( target, source, sourceDominant, context );
132 mergeModel_Version( target, source, sourceDominant, context );
133 mergeModel_Packaging( target, source, sourceDominant, context );
134 mergeModel_Name( target, source, sourceDominant, context );
135 mergeModel_Description( target, source, sourceDominant, context );
136 mergeModel_Url( target, source, sourceDominant, context );
137 mergeModel_InceptionYear( target, source, sourceDominant, context );
138 mergeModel_Organization( target, source, sourceDominant, context );
139 mergeModel_Licenses( target, source, sourceDominant, context );
140 mergeModel_MailingLists( target, source, sourceDominant, context );
141 mergeModel_Developers( target, source, sourceDominant, context );
142 mergeModel_Contributors( target, source, sourceDominant, context );
143 mergeModel_IssueManagement( target, source, sourceDominant, context );
144 mergeModel_Scm( target, source, sourceDominant, context );
145 mergeModel_CiManagement( target, source, sourceDominant, context );
146 mergeModel_Prerequisites( target, source, sourceDominant, context );
147 mergeModel_Build( target, source, sourceDominant, context );
148 mergeModel_Profiles( target, source, sourceDominant, context );
149 }
150
151 protected void mergeModel_ModelVersion( Model target, Model source, boolean sourceDominant,
152 Map<Object, Object> context )
153 {
154 String src = source.getModelVersion();
155 if ( src != null )
156 {
157 if ( sourceDominant || target.getModelVersion() == null )
158 {
159 target.setModelVersion( src );
160 target.setLocation( "modelVersion", source.getLocation( "modelVersion" ) );
161 }
162 }
163 }
164
165 protected void mergeModel_Parent( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
166 {
167 Parent src = source.getParent();
168 if ( src != null )
169 {
170 Parent tgt = target.getParent();
171 if ( tgt == null )
172 {
173 tgt = new Parent();
174 tgt.setRelativePath( null );
175 target.setParent( tgt );
176 }
177 mergeParent( tgt, src, sourceDominant, context );
178 }
179 }
180
181 protected void mergeModel_GroupId( Model target, Model source, boolean sourceDominant,
182 Map<Object, Object> context )
183 {
184 String src = source.getGroupId();
185 if ( src != null )
186 {
187 if ( sourceDominant || target.getGroupId() == null )
188 {
189 target.setGroupId( src );
190 target.setLocation( "groupId", source.getLocation( "groupId" ) );
191 }
192 }
193 }
194
195 protected void mergeModel_ArtifactId( Model target, Model source, boolean sourceDominant,
196 Map<Object, Object> context )
197 {
198 String src = source.getArtifactId();
199 if ( src != null )
200 {
201 if ( sourceDominant || target.getArtifactId() == null )
202 {
203 target.setArtifactId( src );
204 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
205 }
206 }
207 }
208
209 protected void mergeModel_Version( Model target, Model source, boolean sourceDominant,
210 Map<Object, Object> context )
211 {
212 String src = source.getVersion();
213 if ( src != null )
214 {
215 if ( sourceDominant || target.getVersion() == null )
216 {
217 target.setVersion( src );
218 target.setLocation( "version", source.getLocation( "version" ) );
219 }
220 }
221 }
222
223 protected void mergeModel_Packaging( Model target, Model source, boolean sourceDominant,
224 Map<Object, Object> context )
225 {
226 String src = source.getPackaging();
227 if ( src != null )
228 {
229 if ( sourceDominant || target.getPackaging() == null )
230 {
231 target.setPackaging( src );
232 target.setLocation( "packaging", source.getLocation( "packaging" ) );
233 }
234 }
235 }
236
237 protected void mergeModel_Name( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
238 {
239 String src = source.getName();
240 if ( src != null )
241 {
242 if ( sourceDominant || target.getName() == null )
243 {
244 target.setName( src );
245 target.setLocation( "name", source.getLocation( "name" ) );
246 }
247 }
248 }
249
250 protected void mergeModel_Description( Model target, Model source, boolean sourceDominant,
251 Map<Object, Object> context )
252 {
253 String src = source.getDescription();
254 if ( src != null )
255 {
256 if ( sourceDominant || target.getDescription() == null )
257 {
258 target.setDescription( src );
259 target.setLocation( "description", source.getLocation( "description" ) );
260 }
261 }
262 }
263
264 protected void mergeModel_Url( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
265 {
266 String src = source.getUrl();
267 if ( src != null )
268 {
269 if ( sourceDominant || target.getUrl() == null )
270 {
271 target.setUrl( src );
272 target.setLocation( "url", source.getLocation( "url" ) );
273 }
274 }
275 }
276
277 protected void mergeModel_InceptionYear( Model target, Model source, boolean sourceDominant,
278 Map<Object, Object> context )
279 {
280 String src = source.getInceptionYear();
281 if ( src != null )
282 {
283 if ( sourceDominant || target.getInceptionYear() == null )
284 {
285 target.setInceptionYear( src );
286 target.setLocation( "inceptionYear", source.getLocation( "inceptionYear" ) );
287 }
288 }
289 }
290
291 protected void mergeModel_Organization( Model target, Model source, boolean sourceDominant,
292 Map<Object, Object> context )
293 {
294 Organization src = source.getOrganization();
295 if ( src != null )
296 {
297 Organization tgt = target.getOrganization();
298 if ( tgt == null )
299 {
300 tgt = new Organization();
301 target.setOrganization( tgt );
302 }
303 mergeOrganization( tgt, src, sourceDominant, context );
304 }
305 }
306
307 protected void mergeModel_Licenses( Model target, Model source, boolean sourceDominant,
308 Map<Object, Object> context )
309 {
310 List<License> src = source.getLicenses();
311 if ( !src.isEmpty() )
312 {
313 List<License> tgt = target.getLicenses();
314 Map<Object, License> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
315
316 for ( License element : tgt )
317 {
318 Object key = getLicenseKey( element );
319 merged.put( key, element );
320 }
321
322 for ( License element : src )
323 {
324 Object key = getLicenseKey( element );
325 if ( sourceDominant || !merged.containsKey( key ) )
326 {
327 merged.put( key, element );
328 }
329 }
330
331 target.setLicenses( new ArrayList<>( merged.values() ) );
332 }
333 }
334
335 protected void mergeModel_MailingLists( Model target, Model source, boolean sourceDominant,
336 Map<Object, Object> context )
337 {
338 List<MailingList> src = source.getMailingLists();
339 if ( !src.isEmpty() )
340 {
341 List<MailingList> tgt = target.getMailingLists();
342 Map<Object, MailingList> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
343
344 for ( MailingList element : tgt )
345 {
346 Object key = getMailingListKey( element );
347 merged.put( key, element );
348 }
349
350 for ( MailingList element : src )
351 {
352 Object key = getMailingListKey( element );
353 if ( sourceDominant || !merged.containsKey( key ) )
354 {
355 merged.put( key, element );
356 }
357 }
358
359 target.setMailingLists( new ArrayList<>( merged.values() ) );
360 }
361 }
362
363 protected void mergeModel_Developers( Model target, Model source, boolean sourceDominant,
364 Map<Object, Object> context )
365 {
366 List<Developer> src = source.getDevelopers();
367 if ( !src.isEmpty() )
368 {
369 List<Developer> tgt = target.getDevelopers();
370 Map<Object, Developer> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
371
372 for ( Developer element : tgt )
373 {
374 Object key = getDeveloperKey( element );
375 merged.put( key, element );
376 }
377
378 for ( Developer element : src )
379 {
380 Object key = getDeveloperKey( element );
381 if ( sourceDominant || !merged.containsKey( key ) )
382 {
383 merged.put( key, element );
384 }
385 }
386
387 target.setDevelopers( new ArrayList<>( merged.values() ) );
388 }
389 }
390
391 protected void mergeModel_Contributors( Model target, Model source, boolean sourceDominant,
392 Map<Object, Object> context )
393 {
394 List<Contributor> src = source.getContributors();
395 if ( !src.isEmpty() )
396 {
397 List<Contributor> tgt = target.getContributors();
398 Map<Object, Contributor> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
399
400 for ( Contributor element : tgt )
401 {
402 Object key = getContributorKey( element );
403 merged.put( key, element );
404 }
405
406 for ( Contributor element : src )
407 {
408 Object key = getContributorKey( element );
409 if ( sourceDominant || !merged.containsKey( key ) )
410 {
411 merged.put( key, element );
412 }
413 }
414
415 target.setContributors( new ArrayList<>( merged.values() ) );
416 }
417 }
418
419 protected void mergeModel_IssueManagement( Model target, Model source, boolean sourceDominant,
420 Map<Object, Object> context )
421 {
422 IssueManagement src = source.getIssueManagement();
423 if ( src != null )
424 {
425 IssueManagement tgt = target.getIssueManagement();
426 if ( tgt == null )
427 {
428 tgt = new IssueManagement();
429 target.setIssueManagement( tgt );
430 }
431 mergeIssueManagement( tgt, src, sourceDominant, context );
432 }
433 }
434
435 protected void mergeModel_Scm( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
436 {
437 Scm src = source.getScm();
438 if ( src != null )
439 {
440 Scm tgt = target.getScm();
441 if ( tgt == null )
442 {
443 tgt = new Scm();
444 tgt.setTag( null );
445 target.setScm( tgt );
446 }
447 mergeScm( tgt, src, sourceDominant, context );
448 }
449 }
450
451 protected void mergeModel_CiManagement( Model target, Model source, boolean sourceDominant,
452 Map<Object, Object> context )
453 {
454 CiManagement src = source.getCiManagement();
455 if ( src != null )
456 {
457 CiManagement tgt = target.getCiManagement();
458 if ( tgt == null )
459 {
460 tgt = new CiManagement();
461 target.setCiManagement( tgt );
462 }
463 mergeCiManagement( tgt, src, sourceDominant, context );
464 }
465 }
466
467 protected void mergeModel_Prerequisites( Model target, Model source, boolean sourceDominant,
468 Map<Object, Object> context )
469 {
470 Prerequisites src = source.getPrerequisites();
471 if ( src != null )
472 {
473 Prerequisites tgt = target.getPrerequisites();
474 if ( tgt == null )
475 {
476 tgt = new Prerequisites();
477 tgt.setMaven( null );
478 target.setPrerequisites( tgt );
479 }
480 mergePrerequisites( tgt, src, sourceDominant, context );
481 }
482 }
483
484 protected void mergeModel_Build( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
485 {
486 Build src = source.getBuild();
487 if ( src != null )
488 {
489 Build tgt = target.getBuild();
490 if ( tgt == null )
491 {
492 tgt = new Build();
493 target.setBuild( tgt );
494 }
495 mergeBuild( tgt, src, sourceDominant, context );
496 }
497 }
498
499 protected void mergeModel_Profiles( Model target, Model source, boolean sourceDominant,
500 Map<Object, Object> context )
501 {
502 List<Profile> src = source.getProfiles();
503 if ( !src.isEmpty() )
504 {
505 List<Profile> tgt = target.getProfiles();
506 Map<Object, Profile> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
507
508 for ( Profile element : tgt )
509 {
510 Object key = getProfileKey( element );
511 merged.put( key, element );
512 }
513
514 for ( Profile element : src )
515 {
516 Object key = getProfileKey( element );
517 if ( sourceDominant || !merged.containsKey( key ) )
518 {
519 merged.put( key, element );
520 }
521 }
522
523 target.setProfiles( new ArrayList<>( merged.values() ) );
524 }
525 }
526
527 protected void mergeModelBase( ModelBase target, ModelBase source, boolean sourceDominant,
528 Map<Object, Object> context )
529 {
530 mergeModelBase_DistributionManagement( target, source, sourceDominant, context );
531 mergeModelBase_Modules( target, source, sourceDominant, context );
532 mergeModelBase_Repositories( target, source, sourceDominant, context );
533 mergeModelBase_PluginRepositories( target, source, sourceDominant, context );
534 mergeModelBase_Dependencies( target, source, sourceDominant, context );
535 mergeModelBase_Reporting( target, source, sourceDominant, context );
536 mergeModelBase_DependencyManagement( target, source, sourceDominant, context );
537 mergeModelBase_Properties( target, source, sourceDominant, context );
538 }
539
540 protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boolean sourceDominant,
541 Map<Object, Object> context )
542 {
543 List<String> src = source.getModules();
544 if ( !src.isEmpty() )
545 {
546 List<String> tgt = target.getModules();
547 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
548 merged.addAll( tgt );
549 merged.addAll( src );
550 target.setModules( merged );
551 }
552 }
553
554 protected void mergeModelBase_Dependencies( ModelBase target, ModelBase source, boolean sourceDominant,
555 Map<Object, Object> context )
556 {
557 List<Dependency> src = source.getDependencies();
558 if ( !src.isEmpty() )
559 {
560 List<Dependency> tgt = target.getDependencies();
561 Map<Object, Dependency> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
562
563 for ( Dependency element : tgt )
564 {
565 Object key = getDependencyKey( element );
566 merged.put( key, element );
567 }
568
569 for ( Dependency element : src )
570 {
571 Object key = getDependencyKey( element );
572 if ( sourceDominant || !merged.containsKey( key ) )
573 {
574 merged.put( key, element );
575 }
576 }
577
578 target.setDependencies( new ArrayList<>( merged.values() ) );
579 }
580 }
581
582 protected void mergeModelBase_Repositories( ModelBase target, ModelBase source, boolean sourceDominant,
583 Map<Object, Object> context )
584 {
585 List<Repository> src = source.getRepositories();
586 if ( !src.isEmpty() )
587 {
588 List<Repository> tgt = target.getRepositories();
589 Map<Object, Repository> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
590
591 for ( Repository element : tgt )
592 {
593 Object key = getRepositoryKey( element );
594 merged.put( key, element );
595 }
596
597 for ( Repository element : src )
598 {
599 Object key = getRepositoryKey( element );
600 if ( sourceDominant || !merged.containsKey( key ) )
601 {
602 merged.put( key, element );
603 }
604 }
605
606 target.setRepositories( new ArrayList<>( merged.values() ) );
607 }
608 }
609
610 protected void mergeModelBase_PluginRepositories( ModelBase target, ModelBase source, boolean sourceDominant,
611 Map<Object, Object> context )
612 {
613 List<Repository> src = source.getPluginRepositories();
614 if ( !src.isEmpty() )
615 {
616 List<Repository> tgt = target.getPluginRepositories();
617 Map<Object, Repository> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
618
619 for ( Repository element : tgt )
620 {
621 Object key = getRepositoryKey( element );
622 merged.put( key, element );
623 }
624
625 for ( Repository element : src )
626 {
627 Object key = getRepositoryKey( element );
628 if ( sourceDominant || !merged.containsKey( key ) )
629 {
630 merged.put( key, element );
631 }
632 }
633
634 target.setPluginRepositories( new ArrayList<>( merged.values() ) );
635 }
636 }
637
638 protected void mergeModelBase_DistributionManagement( ModelBase target, ModelBase source, boolean sourceDominant,
639 Map<Object, Object> context )
640 {
641 DistributionManagement src = source.getDistributionManagement();
642 if ( src != null )
643 {
644 DistributionManagement tgt = target.getDistributionManagement();
645 if ( tgt == null )
646 {
647 tgt = new DistributionManagement();
648 target.setDistributionManagement( tgt );
649 }
650 mergeDistributionManagement( tgt, src, sourceDominant, context );
651 }
652 }
653
654 protected void mergeModelBase_Reporting( ModelBase target, ModelBase source, boolean sourceDominant,
655 Map<Object, Object> context )
656 {
657 Reporting src = source.getReporting();
658 if ( src != null )
659 {
660 Reporting tgt = target.getReporting();
661 if ( tgt == null )
662 {
663 tgt = new Reporting();
664 target.setReporting( tgt );
665 }
666 mergeReporting( tgt, src, sourceDominant, context );
667 }
668 }
669
670 protected void mergeModelBase_DependencyManagement( ModelBase target, ModelBase source, boolean sourceDominant,
671 Map<Object, Object> context )
672 {
673 DependencyManagement src = source.getDependencyManagement();
674 if ( src != null )
675 {
676 DependencyManagement tgt = target.getDependencyManagement();
677 if ( tgt == null )
678 {
679 tgt = new DependencyManagement();
680 target.setDependencyManagement( tgt );
681 }
682 mergeDependencyManagement( tgt, src, sourceDominant, context );
683 }
684 }
685
686 protected void mergeModelBase_Properties( ModelBase target, ModelBase source, boolean sourceDominant,
687 Map<Object, Object> context )
688 {
689 Properties merged = new Properties();
690 if ( sourceDominant )
691 {
692 merged.putAll( target.getProperties() );
693 merged.putAll( source.getProperties() );
694 }
695 else
696 {
697 merged.putAll( source.getProperties() );
698 merged.putAll( target.getProperties() );
699 }
700 target.setProperties( merged );
701 target.setLocation( "properties", InputLocation.merge( target.getLocation( "properties" ),
702 source.getLocation( "properties" ), sourceDominant ) );
703 }
704
705 protected void mergeDistributionManagement( DistributionManagement target, DistributionManagement source,
706 boolean sourceDominant, Map<Object, Object> context )
707 {
708 mergeDistributionManagement_Repository( target, source, sourceDominant, context );
709 mergeDistributionManagement_SnapshotRepository( target, source, sourceDominant, context );
710 mergeDistributionManagement_Site( target, source, sourceDominant, context );
711 mergeDistributionManagement_Status( target, source, sourceDominant, context );
712 mergeDistributionManagement_DownloadUrl( target, source, sourceDominant, context );
713 }
714
715 protected void mergeDistributionManagement_Repository( DistributionManagement target,
716 DistributionManagement source, boolean sourceDominant,
717 Map<Object, Object> context )
718 {
719 DeploymentRepository src = source.getRepository();
720 if ( src != null )
721 {
722 DeploymentRepository tgt = target.getRepository();
723 if ( tgt == null )
724 {
725 tgt = new DeploymentRepository();
726 target.setRepository( tgt );
727 }
728 mergeDeploymentRepository( tgt, src, sourceDominant, context );
729 }
730 }
731
732 protected void mergeDistributionManagement_SnapshotRepository( DistributionManagement target,
733 DistributionManagement source,
734 boolean sourceDominant,
735 Map<Object, Object> context )
736 {
737 DeploymentRepository src = source.getSnapshotRepository();
738 if ( src != null )
739 {
740 DeploymentRepository tgt = target.getSnapshotRepository();
741 if ( tgt == null )
742 {
743 tgt = new DeploymentRepository();
744 target.setSnapshotRepository( tgt );
745 }
746 mergeDeploymentRepository( tgt, src, sourceDominant, context );
747 }
748 }
749
750 protected void mergeDistributionManagement_Site( DistributionManagement target, DistributionManagement source,
751 boolean sourceDominant, Map<Object, Object> context )
752 {
753 Site src = source.getSite();
754 if ( src != null )
755 {
756 Site tgt = target.getSite();
757 if ( tgt == null )
758 {
759 tgt = new Site();
760 target.setSite( tgt );
761 }
762 mergeSite( tgt, src, sourceDominant, context );
763 }
764 }
765
766 protected void mergeDistributionManagement_Status( DistributionManagement target, DistributionManagement source,
767 boolean sourceDominant, Map<Object, Object> context )
768 {
769 String src = source.getStatus();
770 if ( src != null )
771 {
772 if ( sourceDominant || target.getStatus() == null )
773 {
774 target.setStatus( src );
775 target.setLocation( "status", source.getLocation( "status" ) );
776 }
777 }
778 }
779
780 protected void mergeDistributionManagement_DownloadUrl( DistributionManagement target,
781 DistributionManagement source, boolean sourceDominant,
782 Map<Object, Object> context )
783 {
784 String src = source.getDownloadUrl();
785 if ( src != null )
786 {
787 if ( sourceDominant || target.getDownloadUrl() == null )
788 {
789 target.setDownloadUrl( src );
790 target.setLocation( "downloadUrl", source.getLocation( "downloadUrl" ) );
791 }
792 }
793 }
794
795 protected void mergeRelocation( Relocation target, Relocation source, boolean sourceDominant,
796 Map<Object, Object> context )
797 {
798 mergeRelocation_GroupId( target, source, sourceDominant, context );
799 mergeRelocation_ArtifactId( target, source, sourceDominant, context );
800 mergeRelocation_Version( target, source, sourceDominant, context );
801 mergeRelocation_Message( target, source, sourceDominant, context );
802 }
803
804 protected void mergeRelocation_GroupId( Relocation target, Relocation source, boolean sourceDominant,
805 Map<Object, Object> context )
806 {
807 String src = source.getGroupId();
808 if ( src != null )
809 {
810 if ( sourceDominant || target.getGroupId() == null )
811 {
812 target.setGroupId( src );
813 target.setLocation( "groupId", source.getLocation( "groupId" ) );
814 }
815 }
816 }
817
818 protected void mergeRelocation_ArtifactId( Relocation target, Relocation source, boolean sourceDominant,
819 Map<Object, Object> context )
820 {
821 String src = source.getArtifactId();
822 if ( src != null )
823 {
824 if ( sourceDominant || target.getArtifactId() == null )
825 {
826 target.setArtifactId( src );
827 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
828 }
829 }
830 }
831
832 protected void mergeRelocation_Version( Relocation target, Relocation source, boolean sourceDominant,
833 Map<Object, Object> context )
834 {
835 String src = source.getVersion();
836 if ( src != null )
837 {
838 if ( sourceDominant || target.getVersion() == null )
839 {
840 target.setVersion( src );
841 target.setLocation( "version", source.getLocation( "version" ) );
842 }
843 }
844 }
845
846 protected void mergeRelocation_Message( Relocation target, Relocation source, boolean sourceDominant,
847 Map<Object, Object> context )
848 {
849 String src = source.getMessage();
850 if ( src != null )
851 {
852 if ( sourceDominant || target.getMessage() == null )
853 {
854 target.setMessage( src );
855 target.setLocation( "message", source.getLocation( "message" ) );
856 }
857 }
858 }
859
860 protected void mergeDeploymentRepository( DeploymentRepository target, DeploymentRepository source,
861 boolean sourceDominant, Map<Object, Object> context )
862 {
863 mergeRepository( target, source, sourceDominant, context );
864 mergeDeploymentRepository_UniqueVersion( target, source, sourceDominant, context );
865 }
866
867 protected void mergeDeploymentRepository_UniqueVersion( DeploymentRepository target, DeploymentRepository source,
868 boolean sourceDominant, Map<Object, Object> context )
869 {
870 if ( sourceDominant )
871 {
872 target.setUniqueVersion( source.isUniqueVersion() );
873 target.setLocation( "uniqueVersion", source.getLocation( "uniqueVersion" ) );
874 }
875 }
876
877 protected void mergeSite( Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
878 {
879 mergeSite_Id( target, source, sourceDominant, context );
880 mergeSite_Name( target, source, sourceDominant, context );
881 mergeSite_Url( target, source, sourceDominant, context );
882 }
883
884 protected void mergeSite_Id( Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
885 {
886 String src = source.getId();
887 if ( src != null )
888 {
889 if ( sourceDominant || target.getId() == null )
890 {
891 target.setId( src );
892 target.setLocation( "id", source.getLocation( "id" ) );
893 }
894 }
895 }
896
897 protected void mergeSite_Name( Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
898 {
899 String src = source.getName();
900 if ( src != null )
901 {
902 if ( sourceDominant || target.getName() == null )
903 {
904 target.setName( src );
905 target.setLocation( "name", source.getLocation( "name" ) );
906 }
907 }
908 }
909
910 protected void mergeSite_Url( Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
911 {
912 String src = source.getUrl();
913 if ( src != null )
914 {
915 if ( sourceDominant || target.getUrl() == null )
916 {
917 target.setUrl( src );
918 target.setLocation( "url", source.getLocation( "url" ) );
919 }
920 }
921 }
922
923 protected void mergeRepository( Repository target, Repository source, boolean sourceDominant,
924 Map<Object, Object> context )
925 {
926 mergeRepositoryBase( target, source, sourceDominant, context );
927 mergeRepository_Releases( target, source, sourceDominant, context );
928 mergeRepository_Snapshots( target, source, sourceDominant, context );
929 }
930
931 protected void mergeRepository_Releases( Repository target, Repository source, boolean sourceDominant,
932 Map<Object, Object> context )
933 {
934 RepositoryPolicy src = source.getReleases();
935 if ( src != null )
936 {
937 RepositoryPolicy tgt = target.getReleases();
938 if ( tgt == null )
939 {
940 tgt = new RepositoryPolicy();
941 target.setReleases( tgt );
942 }
943 mergeRepositoryPolicy( tgt, src, sourceDominant, context );
944 }
945 }
946
947 protected void mergeRepository_Snapshots( Repository target, Repository source, boolean sourceDominant,
948 Map<Object, Object> context )
949 {
950 RepositoryPolicy src = source.getSnapshots();
951 if ( src != null )
952 {
953 RepositoryPolicy tgt = target.getSnapshots();
954 if ( tgt == null )
955 {
956 tgt = new RepositoryPolicy();
957 target.setSnapshots( tgt );
958 }
959 mergeRepositoryPolicy( tgt, src, sourceDominant, context );
960 }
961 }
962
963 protected void mergeRepositoryBase( RepositoryBase target, RepositoryBase source, boolean sourceDominant,
964 Map<Object, Object> context )
965 {
966 mergeRepositoryBase_Id( target, source, sourceDominant, context );
967 mergeRepositoryBase_Name( target, source, sourceDominant, context );
968 mergeRepositoryBase_Url( target, source, sourceDominant, context );
969 mergeRepositoryBase_Layout( target, source, sourceDominant, context );
970 }
971
972 protected void mergeRepositoryBase_Id( RepositoryBase target, RepositoryBase source, boolean sourceDominant,
973 Map<Object, Object> context )
974 {
975 String src = source.getId();
976 if ( src != null )
977 {
978 if ( sourceDominant || target.getId() == null )
979 {
980 target.setId( src );
981 target.setLocation( "id", source.getLocation( "id" ) );
982 }
983 }
984 }
985
986 protected void mergeRepositoryBase_Url( RepositoryBase target, RepositoryBase source, boolean sourceDominant,
987 Map<Object, Object> context )
988 {
989 String src = source.getUrl();
990 if ( src != null )
991 {
992 if ( sourceDominant || target.getUrl() == null )
993 {
994 target.setUrl( src );
995 target.setLocation( "url", source.getLocation( "url" ) );
996 }
997 }
998 }
999
1000 protected void mergeRepositoryBase_Name( RepositoryBase target, RepositoryBase source, boolean sourceDominant,
1001 Map<Object, Object> context )
1002 {
1003 String src = source.getName();
1004 if ( src != null )
1005 {
1006 if ( sourceDominant || target.getName() == null )
1007 {
1008 target.setName( src );
1009 target.setLocation( "name", source.getLocation( "name" ) );
1010 }
1011 }
1012 }
1013
1014 protected void mergeRepositoryBase_Layout( RepositoryBase target, RepositoryBase source, boolean sourceDominant,
1015 Map<Object, Object> context )
1016 {
1017 String src = source.getLayout();
1018 if ( src != null )
1019 {
1020 if ( sourceDominant || target.getLayout() == null )
1021 {
1022 target.setLayout( src );
1023 target.setLocation( "layout", source.getLocation( "layout" ) );
1024 }
1025 }
1026 }
1027
1028 protected void mergeRepositoryPolicy( RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant,
1029 Map<Object, Object> context )
1030 {
1031 mergeRepositoryPolicy_Enabled( target, source, sourceDominant, context );
1032 mergeRepositoryPolicy_UpdatePolicy( target, source, sourceDominant, context );
1033 mergeRepositoryPolicy_ChecksumPolicy( target, source, sourceDominant, context );
1034 }
1035
1036 protected void mergeRepositoryPolicy_Enabled( RepositoryPolicy target, RepositoryPolicy source,
1037 boolean sourceDominant, Map<Object, Object> context )
1038 {
1039 String src = source.getEnabled();
1040 if ( src != null )
1041 {
1042 if ( sourceDominant || target.getEnabled() == null )
1043 {
1044 target.setEnabled( src );
1045 target.setLocation( "enabled", source.getLocation( "enabled" ) );
1046 }
1047 }
1048 }
1049
1050 protected void mergeRepositoryPolicy_UpdatePolicy( RepositoryPolicy target, RepositoryPolicy source,
1051 boolean sourceDominant, Map<Object, Object> context )
1052 {
1053 String src = source.getUpdatePolicy();
1054 if ( src != null )
1055 {
1056 if ( sourceDominant || target.getUpdatePolicy() == null )
1057 {
1058 target.setUpdatePolicy( src );
1059 target.setLocation( "updatePolicy", source.getLocation( "updatePolicy" ) );
1060 }
1061 }
1062 }
1063
1064 protected void mergeRepositoryPolicy_ChecksumPolicy( RepositoryPolicy target, RepositoryPolicy source,
1065 boolean sourceDominant, Map<Object, Object> context )
1066 {
1067 String src = source.getChecksumPolicy();
1068 if ( src != null )
1069 {
1070 if ( sourceDominant || target.getChecksumPolicy() == null )
1071 {
1072 target.setChecksumPolicy( src );
1073 target.setLocation( "checksumPolicy", source.getLocation( "checksumPolicy" ) );
1074 }
1075 }
1076 }
1077
1078 protected void mergeDependency( Dependency target, Dependency source, boolean sourceDominant,
1079 Map<Object, Object> context )
1080 {
1081 mergeDependency_GroupId( target, source, sourceDominant, context );
1082 mergeDependency_ArtifactId( target, source, sourceDominant, context );
1083 mergeDependency_Version( target, source, sourceDominant, context );
1084 mergeDependency_Type( target, source, sourceDominant, context );
1085 mergeDependency_Classifier( target, source, sourceDominant, context );
1086 mergeDependency_Scope( target, source, sourceDominant, context );
1087 mergeDependency_SystemPath( target, source, sourceDominant, context );
1088 mergeDependency_Optional( target, source, sourceDominant, context );
1089 mergeDependency_Exclusions( target, source, sourceDominant, context );
1090 }
1091
1092 protected void mergeDependency_GroupId( Dependency target, Dependency source, boolean sourceDominant,
1093 Map<Object, Object> context )
1094 {
1095 String src = source.getGroupId();
1096 if ( src != null )
1097 {
1098 if ( sourceDominant || target.getGroupId() == null )
1099 {
1100 target.setGroupId( src );
1101 target.setLocation( "groupId", source.getLocation( "groupId" ) );
1102 }
1103 }
1104 }
1105
1106 protected void mergeDependency_ArtifactId( Dependency target, Dependency source, boolean sourceDominant,
1107 Map<Object, Object> context )
1108 {
1109 String src = source.getArtifactId();
1110 if ( src != null )
1111 {
1112 if ( sourceDominant || target.getArtifactId() == null )
1113 {
1114 target.setArtifactId( src );
1115 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
1116 }
1117 }
1118 }
1119
1120 protected void mergeDependency_Version( Dependency target, Dependency source, boolean sourceDominant,
1121 Map<Object, Object> context )
1122 {
1123 String src = source.getVersion();
1124 if ( src != null )
1125 {
1126 if ( sourceDominant || target.getVersion() == null )
1127 {
1128 target.setVersion( src );
1129 target.setLocation( "version", source.getLocation( "version" ) );
1130 }
1131 }
1132 }
1133
1134 protected void mergeDependency_Type( Dependency target, Dependency source, boolean sourceDominant,
1135 Map<Object, Object> context )
1136 {
1137 String src = source.getType();
1138 if ( src != null )
1139 {
1140 if ( sourceDominant || target.getType() == null )
1141 {
1142 target.setType( src );
1143 target.setLocation( "type", source.getLocation( "type" ) );
1144 }
1145 }
1146 }
1147
1148 protected void mergeDependency_Classifier( Dependency target, Dependency source, boolean sourceDominant,
1149 Map<Object, Object> context )
1150 {
1151 String src = source.getClassifier();
1152 if ( src != null )
1153 {
1154 if ( sourceDominant || target.getClassifier() == null )
1155 {
1156 target.setClassifier( src );
1157 target.setLocation( "classifier", source.getLocation( "classifier" ) );
1158 }
1159 }
1160 }
1161
1162 protected void mergeDependency_Scope( Dependency target, Dependency source, boolean sourceDominant,
1163 Map<Object, Object> context )
1164 {
1165 String src = source.getScope();
1166 if ( src != null )
1167 {
1168 if ( sourceDominant || target.getScope() == null )
1169 {
1170 target.setScope( src );
1171 target.setLocation( "scope", source.getLocation( "scope" ) );
1172 }
1173 }
1174 }
1175
1176 protected void mergeDependency_SystemPath( Dependency target, Dependency source, boolean sourceDominant,
1177 Map<Object, Object> context )
1178 {
1179 String src = source.getSystemPath();
1180 if ( src != null )
1181 {
1182 if ( sourceDominant || target.getSystemPath() == null )
1183 {
1184 target.setSystemPath( src );
1185 target.setLocation( "systemPath", source.getLocation( "systemPath" ) );
1186 }
1187 }
1188 }
1189
1190 protected void mergeDependency_Optional( Dependency target, Dependency source, boolean sourceDominant,
1191 Map<Object, Object> context )
1192 {
1193 String src = source.getOptional();
1194 if ( src != null )
1195 {
1196 if ( sourceDominant || target.getOptional() == null )
1197 {
1198 target.setOptional( src );
1199 target.setLocation( "optional", source.getLocation( "optional" ) );
1200 }
1201 }
1202 }
1203
1204 protected void mergeDependency_Exclusions( Dependency target, Dependency source, boolean sourceDominant,
1205 Map<Object, Object> context )
1206 {
1207 List<Exclusion> src = source.getExclusions();
1208 if ( !src.isEmpty() )
1209 {
1210 List<Exclusion> tgt = target.getExclusions();
1211
1212 Map<Object, Exclusion> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
1213
1214 for ( Exclusion element : tgt )
1215 {
1216 Object key = getExclusionKey( element );
1217 merged.put( key, element );
1218 }
1219
1220 for ( Exclusion element : src )
1221 {
1222 Object key = getExclusionKey( element );
1223 if ( sourceDominant || !merged.containsKey( key ) )
1224 {
1225 merged.put( key, element );
1226 }
1227 }
1228
1229 target.setExclusions( new ArrayList<>( merged.values() ) );
1230 }
1231 }
1232
1233 protected void mergeExclusion( Exclusion target, Exclusion source, boolean sourceDominant,
1234 Map<Object, Object> context )
1235 {
1236 mergeExclusion_GroupId( target, source, sourceDominant, context );
1237 mergeExclusion_ArtifactId( target, source, sourceDominant, context );
1238 }
1239
1240 protected void mergeExclusion_GroupId( Exclusion target, Exclusion source, boolean sourceDominant,
1241 Map<Object, Object> context )
1242 {
1243 String src = source.getGroupId();
1244 if ( src != null )
1245 {
1246 if ( sourceDominant || target.getGroupId() == null )
1247 {
1248 target.setGroupId( src );
1249 target.setLocation( "groupId", source.getLocation( "groupId" ) );
1250 }
1251 }
1252 }
1253
1254 protected void mergeExclusion_ArtifactId( Exclusion target, Exclusion source, boolean sourceDominant,
1255 Map<Object, Object> context )
1256 {
1257 String src = source.getArtifactId();
1258 if ( src != null )
1259 {
1260 if ( sourceDominant || target.getArtifactId() == null )
1261 {
1262 target.setArtifactId( src );
1263 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
1264 }
1265 }
1266 }
1267
1268 protected void mergeReporting( Reporting target, Reporting source, boolean sourceDominant,
1269 Map<Object, Object> context )
1270 {
1271 mergeReporting_OutputDirectory( target, source, sourceDominant, context );
1272 mergeReporting_ExcludeDefaults( target, source, sourceDominant, context );
1273 mergeReporting_Plugins( target, source, sourceDominant, context );
1274 }
1275
1276 protected void mergeReporting_OutputDirectory( Reporting target, Reporting source, boolean sourceDominant,
1277 Map<Object, Object> context )
1278 {
1279 String src = source.getOutputDirectory();
1280 if ( src != null )
1281 {
1282 if ( sourceDominant || target.getOutputDirectory() == null )
1283 {
1284 target.setOutputDirectory( src );
1285 target.setLocation( "outputDirectory", source.getLocation( "outputDirectory" ) );
1286 }
1287 }
1288 }
1289
1290 protected void mergeReporting_ExcludeDefaults( Reporting target, Reporting source, boolean sourceDominant,
1291 Map<Object, Object> context )
1292 {
1293 String src = source.getExcludeDefaults();
1294 if ( src != null )
1295 {
1296 if ( sourceDominant || target.getExcludeDefaults() == null )
1297 {
1298 target.setExcludeDefaults( src );
1299 target.setLocation( "excludeDefaults", source.getLocation( "excludeDefaults" ) );
1300 }
1301 }
1302 }
1303
1304 protected void mergeReporting_Plugins( Reporting target, Reporting source, boolean sourceDominant,
1305 Map<Object, Object> context )
1306 {
1307 List<ReportPlugin> src = source.getPlugins();
1308 if ( !src.isEmpty() )
1309 {
1310 List<ReportPlugin> tgt = target.getPlugins();
1311 Map<Object, ReportPlugin> merged =
1312 new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
1313
1314 for ( ReportPlugin element : tgt )
1315 {
1316 Object key = getReportPluginKey( element );
1317 merged.put( key, element );
1318 }
1319
1320 for ( ReportPlugin element : src )
1321 {
1322 Object key = getReportPluginKey( element );
1323 if ( sourceDominant || !merged.containsKey( key ) )
1324 {
1325 merged.put( key, element );
1326 }
1327 }
1328
1329 target.setPlugins( new ArrayList<>( merged.values() ) );
1330 }
1331 }
1332
1333 protected void mergeReportPlugin( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1334 Map<Object, Object> context )
1335 {
1336 mergeConfigurationContainer( target, source, sourceDominant, context );
1337 mergeReportPlugin_GroupId( target, source, sourceDominant, context );
1338 mergeReportPlugin_ArtifactId( target, source, sourceDominant, context );
1339 mergeReportPlugin_Version( target, source, sourceDominant, context );
1340 mergeReportPlugin_ReportSets( target, source, sourceDominant, context );
1341 }
1342
1343 protected void mergeReportPlugin_GroupId( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1344 Map<Object, Object> context )
1345 {
1346 String src = source.getGroupId();
1347 if ( src != null )
1348 {
1349 if ( sourceDominant || target.getGroupId() == null )
1350 {
1351 target.setGroupId( src );
1352 target.setLocation( "groupId", source.getLocation( "groupId" ) );
1353 }
1354 }
1355 }
1356
1357 protected void mergeReportPlugin_ArtifactId( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1358 Map<Object, Object> context )
1359 {
1360 String src = source.getArtifactId();
1361 if ( src != null )
1362 {
1363 if ( sourceDominant || target.getArtifactId() == null )
1364 {
1365 target.setArtifactId( src );
1366 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
1367 }
1368 }
1369 }
1370
1371 protected void mergeReportPlugin_Version( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1372 Map<Object, Object> context )
1373 {
1374 String src = source.getVersion();
1375 if ( src != null )
1376 {
1377 if ( sourceDominant || target.getVersion() == null )
1378 {
1379 target.setVersion( src );
1380 target.setLocation( "version", source.getLocation( "version" ) );
1381 }
1382 }
1383 }
1384
1385 protected void mergeReportPlugin_ReportSets( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1386 Map<Object, Object> context )
1387 {
1388 List<ReportSet> src = source.getReportSets();
1389 if ( !src.isEmpty() )
1390 {
1391 List<ReportSet> tgt = target.getReportSets();
1392 Map<Object, ReportSet> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
1393
1394 for ( ReportSet element : tgt )
1395 {
1396 Object key = getReportSetKey( element );
1397 merged.put( key, element );
1398 }
1399
1400 for ( ReportSet element : src )
1401 {
1402 Object key = getReportSetKey( element );
1403 if ( sourceDominant || !merged.containsKey( key ) )
1404 {
1405 merged.put( key, element );
1406 }
1407 }
1408
1409 target.setReportSets( new ArrayList<>( merged.values() ) );
1410 }
1411 }
1412
1413 protected void mergeReportSet( ReportSet target, ReportSet source, boolean sourceDominant,
1414 Map<Object, Object> context )
1415 {
1416 mergeConfigurationContainer( target, source, sourceDominant, context );
1417 mergeReportSet_Id( target, source, sourceDominant, context );
1418 mergeReportSet_Reports( target, source, sourceDominant, context );
1419 }
1420
1421 protected void mergeReportSet_Id( ReportSet target, ReportSet source, boolean sourceDominant,
1422 Map<Object, Object> context )
1423 {
1424 String src = source.getId();
1425 if ( src != null )
1426 {
1427 if ( sourceDominant || target.getId() == null )
1428 {
1429 target.setId( src );
1430 target.setLocation( "id", source.getLocation( "id" ) );
1431 }
1432 }
1433 }
1434
1435 protected void mergeReportSet_Reports( ReportSet target, ReportSet source, boolean sourceDominant,
1436 Map<Object, Object> context )
1437 {
1438 List<String> src = source.getReports();
1439 if ( !src.isEmpty() )
1440 {
1441 List<String> tgt = target.getReports();
1442 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
1443 merged.addAll( tgt );
1444 merged.addAll( src );
1445 target.setReports( merged );
1446 }
1447 }
1448
1449 protected void mergeDependencyManagement( DependencyManagement target, DependencyManagement source,
1450 boolean sourceDominant, Map<Object, Object> context )
1451 {
1452 mergeDependencyManagement_Dependencies( target, source, sourceDominant, context );
1453 }
1454
1455 protected void mergeDependencyManagement_Dependencies( DependencyManagement target, DependencyManagement source,
1456 boolean sourceDominant, Map<Object, Object> context )
1457 {
1458 List<Dependency> src = source.getDependencies();
1459 if ( !src.isEmpty() )
1460 {
1461 List<Dependency> tgt = target.getDependencies();
1462 Map<Object, Dependency> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
1463
1464 for ( Dependency element : tgt )
1465 {
1466 Object key = getDependencyKey( element );
1467 merged.put( key, element );
1468 }
1469
1470 for ( Dependency element : src )
1471 {
1472 Object key = getDependencyKey( element );
1473 if ( sourceDominant || !merged.containsKey( key ) )
1474 {
1475 merged.put( key, element );
1476 }
1477 }
1478
1479 target.setDependencies( new ArrayList<>( merged.values() ) );
1480 }
1481 }
1482
1483 protected void mergeParent( Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1484 {
1485 mergeParent_GroupId( target, source, sourceDominant, context );
1486 mergeParent_ArtifactId( target, source, sourceDominant, context );
1487 mergeParent_Version( target, source, sourceDominant, context );
1488 mergeParent_RelativePath( target, source, sourceDominant, context );
1489 }
1490
1491 protected void mergeParent_GroupId( Parent target, Parent source, boolean sourceDominant,
1492 Map<Object, Object> context )
1493 {
1494 String src = source.getGroupId();
1495 if ( src != null )
1496 {
1497 if ( sourceDominant || target.getGroupId() == null )
1498 {
1499 target.setGroupId( src );
1500 target.setLocation( "groupId", source.getLocation( "groupId" ) );
1501 }
1502 }
1503 }
1504
1505 protected void mergeParent_ArtifactId( Parent target, Parent source, boolean sourceDominant,
1506 Map<Object, Object> context )
1507 {
1508 String src = source.getArtifactId();
1509 if ( src != null )
1510 {
1511 if ( sourceDominant || target.getArtifactId() == null )
1512 {
1513 target.setArtifactId( src );
1514 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
1515 }
1516 }
1517 }
1518
1519 protected void mergeParent_Version( Parent target, Parent source, boolean sourceDominant,
1520 Map<Object, Object> context )
1521 {
1522 String src = source.getVersion();
1523 if ( src != null )
1524 {
1525 if ( sourceDominant || target.getVersion() == null )
1526 {
1527 target.setVersion( src );
1528 target.setLocation( "version", source.getLocation( "version" ) );
1529 }
1530 }
1531 }
1532
1533 protected void mergeParent_RelativePath( Parent target, Parent source, boolean sourceDominant,
1534 Map<Object, Object> context )
1535 {
1536 String src = source.getRelativePath();
1537 if ( src != null )
1538 {
1539 if ( sourceDominant || target.getRelativePath() == null )
1540 {
1541 target.setRelativePath( src );
1542 target.setLocation( "relativePath", source.getLocation( "relativePath" ) );
1543 }
1544 }
1545 }
1546
1547 protected void mergeOrganization( Organization target, Organization source, boolean sourceDominant,
1548 Map<Object, Object> context )
1549 {
1550 mergeOrganization_Name( target, source, sourceDominant, context );
1551 mergeOrganization_Url( target, source, sourceDominant, context );
1552 }
1553
1554 protected void mergeOrganization_Name( Organization target, Organization source, boolean sourceDominant,
1555 Map<Object, Object> context )
1556 {
1557 String src = source.getName();
1558 if ( src != null )
1559 {
1560 if ( sourceDominant || target.getName() == null )
1561 {
1562 target.setName( src );
1563 target.setLocation( "name", source.getLocation( "name" ) );
1564 }
1565 }
1566 }
1567
1568 protected void mergeOrganization_Url( Organization target, Organization source, boolean sourceDominant,
1569 Map<Object, Object> context )
1570 {
1571 String src = source.getUrl();
1572 if ( src != null )
1573 {
1574 if ( sourceDominant || target.getUrl() == null )
1575 {
1576 target.setUrl( src );
1577 target.setLocation( "url", source.getLocation( "url" ) );
1578 }
1579 }
1580 }
1581
1582 protected void mergeLicense( License target, License source, boolean sourceDominant, Map<Object, Object> context )
1583 {
1584 mergeLicense_Name( target, source, sourceDominant, context );
1585 mergeLicense_Url( target, source, sourceDominant, context );
1586 mergeLicense_Distribution( target, source, sourceDominant, context );
1587 mergeLicense_Comments( target, source, sourceDominant, context );
1588 }
1589
1590 protected void mergeLicense_Name( License target, License source, boolean sourceDominant,
1591 Map<Object, Object> context )
1592 {
1593 String src = source.getName();
1594 if ( src != null )
1595 {
1596 if ( sourceDominant || target.getName() == null )
1597 {
1598 target.setName( src );
1599 target.setLocation( "name", source.getLocation( "name" ) );
1600 }
1601 }
1602 }
1603
1604 protected void mergeLicense_Url( License target, License source, boolean sourceDominant,
1605 Map<Object, Object> context )
1606 {
1607 String src = source.getUrl();
1608 if ( src != null )
1609 {
1610 if ( sourceDominant || target.getUrl() == null )
1611 {
1612 target.setUrl( src );
1613 target.setLocation( "url", source.getLocation( "url" ) );
1614 }
1615 }
1616 }
1617
1618 protected void mergeLicense_Distribution( License target, License source, boolean sourceDominant,
1619 Map<Object, Object> context )
1620 {
1621 String src = source.getDistribution();
1622 if ( src != null )
1623 {
1624 if ( sourceDominant || target.getDistribution() == null )
1625 {
1626 target.setDistribution( src );
1627 target.setLocation( "distribution", source.getLocation( "distribution" ) );
1628 }
1629 }
1630 }
1631
1632 protected void mergeLicense_Comments( License target, License source, boolean sourceDominant,
1633 Map<Object, Object> context )
1634 {
1635 String src = source.getComments();
1636 if ( src != null )
1637 {
1638 if ( sourceDominant || target.getComments() == null )
1639 {
1640 target.setComments( src );
1641 target.setLocation( "comments", source.getLocation( "comments" ) );
1642 }
1643 }
1644 }
1645
1646 protected void mergeMailingList( MailingList target, MailingList source, boolean sourceDominant,
1647 Map<Object, Object> context )
1648 {
1649 mergeMailingList_Name( target, source, sourceDominant, context );
1650 mergeMailingList_Subscribe( target, source, sourceDominant, context );
1651 mergeMailingList_Unsubscribe( target, source, sourceDominant, context );
1652 mergeMailingList_Post( target, source, sourceDominant, context );
1653 mergeMailingList_OtherArchives( target, source, sourceDominant, context );
1654 }
1655
1656 protected void mergeMailingList_Name( MailingList target, MailingList source, boolean sourceDominant,
1657 Map<Object, Object> context )
1658 {
1659 String src = source.getName();
1660 if ( src != null )
1661 {
1662 if ( sourceDominant || target.getName() == null )
1663 {
1664 target.setName( src );
1665 target.setLocation( "name", source.getLocation( "name" ) );
1666 }
1667 }
1668 }
1669
1670 protected void mergeMailingList_Subscribe( MailingList target, MailingList source, boolean sourceDominant,
1671 Map<Object, Object> context )
1672 {
1673 String src = source.getSubscribe();
1674 if ( src != null )
1675 {
1676 if ( sourceDominant || target.getSubscribe() == null )
1677 {
1678 target.setSubscribe( src );
1679 target.setLocation( "subscribe", source.getLocation( "subscribe" ) );
1680 }
1681 }
1682 }
1683
1684 protected void mergeMailingList_Unsubscribe( MailingList target, MailingList source, boolean sourceDominant,
1685 Map<Object, Object> context )
1686 {
1687 String src = source.getUnsubscribe();
1688 if ( src != null )
1689 {
1690 if ( sourceDominant || target.getUnsubscribe() == null )
1691 {
1692 target.setUnsubscribe( src );
1693 target.setLocation( "unsubscribe", source.getLocation( "unsubscribe" ) );
1694 }
1695 }
1696 }
1697
1698 protected void mergeMailingList_Post( MailingList target, MailingList source, boolean sourceDominant,
1699 Map<Object, Object> context )
1700 {
1701 String src = source.getPost();
1702 if ( src != null )
1703 {
1704 if ( sourceDominant || target.getPost() == null )
1705 {
1706 target.setPost( src );
1707 target.setLocation( "post", source.getLocation( "post" ) );
1708 }
1709 }
1710 }
1711
1712 protected void mergeMailingList_Archive( MailingList target, MailingList source, boolean sourceDominant,
1713 Map<Object, Object> context )
1714 {
1715 String src = source.getArchive();
1716 if ( src != null )
1717 {
1718 if ( sourceDominant || target.getArchive() == null )
1719 {
1720 target.setArchive( src );
1721 target.setLocation( "archive", source.getLocation( "archive" ) );
1722 }
1723 }
1724 }
1725
1726 protected void mergeMailingList_OtherArchives( MailingList target, MailingList source, boolean sourceDominant,
1727 Map<Object, Object> context )
1728 {
1729 List<String> src = source.getOtherArchives();
1730 if ( !src.isEmpty() )
1731 {
1732 List<String> tgt = target.getOtherArchives();
1733 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
1734 merged.addAll( tgt );
1735 merged.addAll( src );
1736 target.setOtherArchives( merged );
1737 }
1738 }
1739
1740 protected void mergeDeveloper( Developer target, Developer source, boolean sourceDominant,
1741 Map<Object, Object> context )
1742 {
1743 mergeContributor( target, source, sourceDominant, context );
1744 mergeDeveloper_Id( target, source, sourceDominant, context );
1745 }
1746
1747 protected void mergeDeveloper_Id( Developer target, Developer source, boolean sourceDominant,
1748 Map<Object, Object> context )
1749 {
1750 String src = source.getId();
1751 if ( src != null )
1752 {
1753 if ( sourceDominant || target.getId() == null )
1754 {
1755 target.setId( src );
1756 target.setLocation( "id", source.getLocation( "id" ) );
1757 }
1758 }
1759 }
1760
1761 protected void mergeContributor( Contributor target, Contributor source, boolean sourceDominant,
1762 Map<Object, Object> context )
1763 {
1764 mergeContributor_Name( target, source, sourceDominant, context );
1765 mergeContributor_Email( target, source, sourceDominant, context );
1766 mergeContributor_Url( target, source, sourceDominant, context );
1767 mergeContributor_Organization( target, source, sourceDominant, context );
1768 mergeContributor_OrganizationUrl( target, source, sourceDominant, context );
1769 mergeContributor_Timezone( target, source, sourceDominant, context );
1770 mergeContributor_Roles( target, source, sourceDominant, context );
1771 mergeContributor_Properties( target, source, sourceDominant, context );
1772 }
1773
1774 protected void mergeContributor_Name( Contributor target, Contributor source, boolean sourceDominant,
1775 Map<Object, Object> context )
1776 {
1777 String src = source.getName();
1778 if ( src != null )
1779 {
1780 if ( sourceDominant || target.getName() == null )
1781 {
1782 target.setName( src );
1783 target.setLocation( "name", source.getLocation( "name" ) );
1784 }
1785 }
1786 }
1787
1788 protected void mergeContributor_Email( Contributor target, Contributor source, boolean sourceDominant,
1789 Map<Object, Object> context )
1790 {
1791 String src = source.getEmail();
1792 if ( src != null )
1793 {
1794 if ( sourceDominant || target.getEmail() == null )
1795 {
1796 target.setEmail( src );
1797 target.setLocation( "email", source.getLocation( "email" ) );
1798 }
1799 }
1800 }
1801
1802 protected void mergeContributor_Url( Contributor target, Contributor source, boolean sourceDominant,
1803 Map<Object, Object> context )
1804 {
1805 String src = source.getUrl();
1806 if ( src != null )
1807 {
1808 if ( sourceDominant || target.getUrl() == null )
1809 {
1810 target.setUrl( src );
1811 target.setLocation( "url", source.getLocation( "url" ) );
1812 }
1813 }
1814 }
1815
1816 protected void mergeContributor_Organization( Contributor target, Contributor source, boolean sourceDominant,
1817 Map<Object, Object> context )
1818 {
1819 String src = source.getOrganization();
1820 if ( src != null )
1821 {
1822 if ( sourceDominant || target.getOrganization() == null )
1823 {
1824 target.setOrganization( src );
1825 target.setLocation( "organization", source.getLocation( "organization" ) );
1826 }
1827 }
1828 }
1829
1830 protected void mergeContributor_OrganizationUrl( Contributor target, Contributor source, boolean sourceDominant,
1831 Map<Object, Object> context )
1832 {
1833 String src = source.getOrganizationUrl();
1834 if ( src != null )
1835 {
1836 if ( sourceDominant || target.getOrganizationUrl() == null )
1837 {
1838 target.setOrganizationUrl( src );
1839 target.setLocation( "organizationUrl", source.getLocation( "organizationUrl" ) );
1840 }
1841 }
1842 }
1843
1844 protected void mergeContributor_Timezone( Contributor target, Contributor source, boolean sourceDominant,
1845 Map<Object, Object> context )
1846 {
1847 String src = source.getTimezone();
1848 if ( src != null )
1849 {
1850 if ( sourceDominant || target.getTimezone() == null )
1851 {
1852 target.setTimezone( src );
1853 target.setLocation( "timezone", source.getLocation( "timezone" ) );
1854 }
1855 }
1856 }
1857
1858 protected void mergeContributor_Roles( Contributor target, Contributor source, boolean sourceDominant,
1859 Map<Object, Object> context )
1860 {
1861 List<String> src = source.getRoles();
1862 if ( !src.isEmpty() )
1863 {
1864 List<String> tgt = target.getRoles();
1865 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
1866 merged.addAll( tgt );
1867 merged.addAll( src );
1868 target.setRoles( merged );
1869 }
1870 }
1871
1872 protected void mergeContributor_Properties( Contributor target, Contributor source, boolean sourceDominant,
1873 Map<Object, Object> context )
1874 {
1875 Properties merged = new Properties();
1876 if ( sourceDominant )
1877 {
1878 merged.putAll( target.getProperties() );
1879 merged.putAll( source.getProperties() );
1880 }
1881 else
1882 {
1883 merged.putAll( source.getProperties() );
1884 merged.putAll( target.getProperties() );
1885 }
1886 target.setProperties( merged );
1887 target.setLocation( "properties", InputLocation.merge( target.getLocation( "properties" ),
1888 source.getLocation( "properties" ), sourceDominant ) );
1889 }
1890
1891 protected void mergeIssueManagement( IssueManagement target, IssueManagement source, boolean sourceDominant,
1892 Map<Object, Object> context )
1893 {
1894 mergeIssueManagement_Url( target, source, sourceDominant, context );
1895 mergeIssueManagement_System( target, source, sourceDominant, context );
1896 }
1897
1898 protected void mergeIssueManagement_System( IssueManagement target, IssueManagement source, boolean sourceDominant,
1899 Map<Object, Object> context )
1900 {
1901 String src = source.getSystem();
1902 if ( src != null )
1903 {
1904 if ( sourceDominant || target.getSystem() == null )
1905 {
1906 target.setSystem( src );
1907 target.setLocation( "system", source.getLocation( "system" ) );
1908 }
1909 }
1910 }
1911
1912 protected void mergeIssueManagement_Url( IssueManagement target, IssueManagement source, boolean sourceDominant,
1913 Map<Object, Object> context )
1914 {
1915 String src = source.getUrl();
1916 if ( src != null )
1917 {
1918 if ( sourceDominant || target.getUrl() == null )
1919 {
1920 target.setUrl( src );
1921 target.setLocation( "url", source.getLocation( "url" ) );
1922 }
1923 }
1924 }
1925
1926 protected void mergeScm( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1927 {
1928 mergeScm_Url( target, source, sourceDominant, context );
1929 mergeScm_Connection( target, source, sourceDominant, context );
1930 mergeScm_DeveloperConnection( target, source, sourceDominant, context );
1931 mergeScm_Tag( target, source, sourceDominant, context );
1932 }
1933
1934 protected void mergeScm_Url( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1935 {
1936 String src = source.getUrl();
1937 if ( src != null )
1938 {
1939 if ( sourceDominant || target.getUrl() == null )
1940 {
1941 target.setUrl( src );
1942 target.setLocation( "url", source.getLocation( "url" ) );
1943 }
1944 }
1945 }
1946
1947 protected void mergeScm_Connection( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1948 {
1949 String src = source.getConnection();
1950 if ( src != null )
1951 {
1952 if ( sourceDominant || target.getConnection() == null )
1953 {
1954 target.setConnection( src );
1955 target.setLocation( "connection", source.getLocation( "connection" ) );
1956 }
1957 }
1958 }
1959
1960 protected void mergeScm_DeveloperConnection( Scm target, Scm source, boolean sourceDominant,
1961 Map<Object, Object> context )
1962 {
1963 String src = source.getDeveloperConnection();
1964 if ( src != null )
1965 {
1966 if ( sourceDominant || target.getDeveloperConnection() == null )
1967 {
1968 target.setDeveloperConnection( src );
1969 target.setLocation( "developerConnection", source.getLocation( "developerConnection" ) );
1970 }
1971 }
1972 }
1973
1974 protected void mergeScm_Tag( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1975 {
1976 String src = source.getTag();
1977 if ( src != null )
1978 {
1979 if ( sourceDominant || target.getTag() == null )
1980 {
1981 target.setTag( src );
1982 target.setLocation( "tag", source.getLocation( "tag" ) );
1983 }
1984 }
1985 }
1986
1987 protected void mergeCiManagement( CiManagement target, CiManagement source, boolean sourceDominant,
1988 Map<Object, Object> context )
1989 {
1990 mergeCiManagement_System( target, source, sourceDominant, context );
1991 mergeCiManagement_Url( target, source, sourceDominant, context );
1992 mergeCiManagement_Notifiers( target, source, sourceDominant, context );
1993 }
1994
1995 protected void mergeCiManagement_System( CiManagement target, CiManagement source, boolean sourceDominant,
1996 Map<Object, Object> context )
1997 {
1998 String src = source.getSystem();
1999 if ( src != null )
2000 {
2001 if ( sourceDominant || target.getSystem() == null )
2002 {
2003 target.setSystem( src );
2004 target.setLocation( "system", source.getLocation( "system" ) );
2005 }
2006 }
2007 }
2008
2009 protected void mergeCiManagement_Url( CiManagement target, CiManagement source, boolean sourceDominant,
2010 Map<Object, Object> context )
2011 {
2012 String src = source.getUrl();
2013 if ( src != null )
2014 {
2015 if ( sourceDominant || target.getUrl() == null )
2016 {
2017 target.setUrl( src );
2018 target.setLocation( "url", source.getLocation( "url" ) );
2019 }
2020 }
2021 }
2022
2023 protected void mergeCiManagement_Notifiers( CiManagement target, CiManagement source, boolean sourceDominant,
2024 Map<Object, Object> context )
2025 {
2026 List<Notifier> src = source.getNotifiers();
2027 if ( !src.isEmpty() )
2028 {
2029 List<Notifier> tgt = target.getNotifiers();
2030 Map<Object, Notifier> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
2031
2032 for ( Notifier element : tgt )
2033 {
2034 Object key = getNotifierKey( element );
2035 merged.put( key, element );
2036 }
2037
2038 for ( Notifier element : src )
2039 {
2040 Object key = getNotifierKey( element );
2041 if ( sourceDominant || !merged.containsKey( key ) )
2042 {
2043 merged.put( key, element );
2044 }
2045 }
2046
2047 target.setNotifiers( new ArrayList<>( merged.values() ) );
2048 }
2049 }
2050
2051 protected void mergeNotifier( Notifier target, Notifier source, boolean sourceDominant,
2052 Map<Object, Object> context )
2053 {
2054 mergeNotifier_Type( target, source, sourceDominant, context );
2055 mergeNotifier_Address( target, source, sourceDominant, context );
2056 mergeNotifier_Configuration( target, source, sourceDominant, context );
2057 mergeNotifier_SendOnError( target, source, sourceDominant, context );
2058 mergeNotifier_SendOnFailure( target, source, sourceDominant, context );
2059 mergeNotifier_SendOnSuccess( target, source, sourceDominant, context );
2060 mergeNotifier_SendOnWarning( target, source, sourceDominant, context );
2061 }
2062
2063 protected void mergeNotifier_Type( Notifier target, Notifier source, boolean sourceDominant,
2064 Map<Object, Object> context )
2065 {
2066 String src = source.getType();
2067 if ( src != null )
2068 {
2069 if ( sourceDominant || target.getType() == null )
2070 {
2071 target.setType( src );
2072 }
2073 }
2074 }
2075
2076 protected void mergeNotifier_Address( Notifier target, Notifier source, boolean sourceDominant,
2077 Map<Object, Object> context )
2078 {
2079 String src = source.getAddress();
2080 if ( src != null )
2081 {
2082 if ( sourceDominant || target.getAddress() == null )
2083 {
2084 target.setAddress( src );
2085 }
2086 }
2087 }
2088
2089 protected void mergeNotifier_Configuration( Notifier target, Notifier source, boolean sourceDominant,
2090 Map<Object, Object> context )
2091 {
2092 Properties merged = new Properties();
2093 if ( sourceDominant )
2094 {
2095 merged.putAll( target.getConfiguration() );
2096 merged.putAll( source.getConfiguration() );
2097 }
2098 else
2099 {
2100 merged.putAll( source.getConfiguration() );
2101 merged.putAll( target.getConfiguration() );
2102 }
2103 target.setConfiguration( merged );
2104 }
2105
2106 protected void mergeNotifier_SendOnError( Notifier target, Notifier source, boolean sourceDominant,
2107 Map<Object, Object> context )
2108 {
2109 if ( sourceDominant )
2110 {
2111 target.setSendOnError( source.isSendOnError() );
2112 }
2113 }
2114
2115 protected void mergeNotifier_SendOnFailure( Notifier target, Notifier source, boolean sourceDominant,
2116 Map<Object, Object> context )
2117 {
2118 if ( sourceDominant )
2119 {
2120 target.setSendOnFailure( source.isSendOnFailure() );
2121 }
2122 }
2123
2124 protected void mergeNotifier_SendOnSuccess( Notifier target, Notifier source, boolean sourceDominant,
2125 Map<Object, Object> context )
2126 {
2127 if ( sourceDominant )
2128 {
2129 target.setSendOnSuccess( source.isSendOnSuccess() );
2130 }
2131 }
2132
2133 protected void mergeNotifier_SendOnWarning( Notifier target, Notifier source, boolean sourceDominant,
2134 Map<Object, Object> context )
2135 {
2136 if ( sourceDominant )
2137 {
2138 target.setSendOnWarning( source.isSendOnWarning() );
2139 }
2140 }
2141
2142 protected void mergePrerequisites( Prerequisites target, Prerequisites source, boolean sourceDominant,
2143 Map<Object, Object> context )
2144 {
2145 mergePrerequisites_Maven( target, source, sourceDominant, context );
2146 }
2147
2148 protected void mergePrerequisites_Maven( Prerequisites target, Prerequisites source, boolean sourceDominant,
2149 Map<Object, Object> context )
2150 {
2151 String src = source.getMaven();
2152 if ( src != null )
2153 {
2154 if ( sourceDominant || target.getMaven() == null )
2155 {
2156 target.setMaven( src );
2157 target.setLocation( "maven", source.getLocation( "maven" ) );
2158 }
2159 }
2160 }
2161
2162 protected void mergeBuild( Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
2163 {
2164 mergeBuildBase( target, source, sourceDominant, context );
2165 mergeBuild_SourceDirectory( target, source, sourceDominant, context );
2166 mergeBuild_ScriptSourceDirectory( target, source, sourceDominant, context );
2167 mergeBuild_TestSourceDirectory( target, source, sourceDominant, context );
2168 mergeBuild_OutputDirectory( target, source, sourceDominant, context );
2169 mergeBuild_TestOutputDirectory( target, source, sourceDominant, context );
2170 mergeBuild_Extensions( target, source, sourceDominant, context );
2171 }
2172
2173 protected void mergeBuild_SourceDirectory( Build target, Build source, boolean sourceDominant,
2174 Map<Object, Object> context )
2175 {
2176 String src = source.getSourceDirectory();
2177 if ( src != null )
2178 {
2179 if ( sourceDominant || target.getSourceDirectory() == null )
2180 {
2181 target.setSourceDirectory( src );
2182 target.setLocation( "sourceDirectory", source.getLocation( "sourceDirectory" ) );
2183 }
2184 }
2185 }
2186
2187 protected void mergeBuild_ScriptSourceDirectory( Build target, Build source, boolean sourceDominant,
2188 Map<Object, Object> context )
2189 {
2190 String src = source.getScriptSourceDirectory();
2191 if ( src != null )
2192 {
2193 if ( sourceDominant || target.getScriptSourceDirectory() == null )
2194 {
2195 target.setScriptSourceDirectory( src );
2196 target.setLocation( "scriptSourceDirectory", source.getLocation( "scriptSourceDirectory" ) );
2197 }
2198 }
2199 }
2200
2201 protected void mergeBuild_TestSourceDirectory( Build target, Build source, boolean sourceDominant,
2202 Map<Object, Object> context )
2203 {
2204 String src = source.getTestSourceDirectory();
2205 if ( src != null )
2206 {
2207 if ( sourceDominant || target.getTestSourceDirectory() == null )
2208 {
2209 target.setTestSourceDirectory( src );
2210 target.setLocation( "testSourceDirectory", source.getLocation( "testSourceDirectory" ) );
2211 }
2212 }
2213 }
2214
2215 protected void mergeBuild_OutputDirectory( Build target, Build source, boolean sourceDominant,
2216 Map<Object, Object> context )
2217 {
2218 String src = source.getOutputDirectory();
2219 if ( src != null )
2220 {
2221 if ( sourceDominant || target.getOutputDirectory() == null )
2222 {
2223 target.setOutputDirectory( src );
2224 target.setLocation( "outputDirectory", source.getLocation( "outputDirectory" ) );
2225 }
2226 }
2227 }
2228
2229 protected void mergeBuild_TestOutputDirectory( Build target, Build source, boolean sourceDominant,
2230 Map<Object, Object> context )
2231 {
2232 String src = source.getTestOutputDirectory();
2233 if ( src != null )
2234 {
2235 if ( sourceDominant || target.getTestOutputDirectory() == null )
2236 {
2237 target.setTestOutputDirectory( src );
2238 target.setLocation( "testOutputDirectory", source.getLocation( "testOutputDirectory" ) );
2239 }
2240 }
2241 }
2242
2243 protected void mergeBuild_Extensions( Build target, Build source, boolean sourceDominant,
2244 Map<Object, Object> context )
2245 {
2246 List<Extension> src = source.getExtensions();
2247 if ( !src.isEmpty() )
2248 {
2249 List<Extension> tgt = target.getExtensions();
2250 Map<Object, Extension> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
2251
2252 for ( Extension element : tgt )
2253 {
2254 Object key = getExtensionKey( element );
2255 merged.put( key, element );
2256 }
2257
2258 for ( Extension element : src )
2259 {
2260 Object key = getExtensionKey( element );
2261 if ( sourceDominant || !merged.containsKey( key ) )
2262 {
2263 merged.put( key, element );
2264 }
2265 }
2266
2267 target.setExtensions( new ArrayList<>( merged.values() ) );
2268 }
2269 }
2270
2271 protected void mergeExtension( Extension target, Extension source, boolean sourceDominant,
2272 Map<Object, Object> context )
2273 {
2274 mergeExtension_GroupId( target, source, sourceDominant, context );
2275 mergeExtension_ArtifactId( target, source, sourceDominant, context );
2276 mergeExtension_Version( target, source, sourceDominant, context );
2277 }
2278
2279 protected void mergeExtension_GroupId( Extension target, Extension source, boolean sourceDominant,
2280 Map<Object, Object> context )
2281 {
2282 String src = source.getGroupId();
2283 if ( src != null )
2284 {
2285 if ( sourceDominant || target.getGroupId() == null )
2286 {
2287 target.setGroupId( src );
2288 target.setLocation( "groupId", source.getLocation( "groupId" ) );
2289 }
2290 }
2291 }
2292
2293 protected void mergeExtension_ArtifactId( Extension target, Extension source, boolean sourceDominant,
2294 Map<Object, Object> context )
2295 {
2296 String src = source.getArtifactId();
2297 if ( src != null )
2298 {
2299 if ( sourceDominant || target.getArtifactId() == null )
2300 {
2301 target.setArtifactId( src );
2302 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
2303 }
2304 }
2305 }
2306
2307 protected void mergeExtension_Version( Extension target, Extension source, boolean sourceDominant,
2308 Map<Object, Object> context )
2309 {
2310 String src = source.getVersion();
2311 if ( src != null )
2312 {
2313 if ( sourceDominant || target.getVersion() == null )
2314 {
2315 target.setVersion( src );
2316 target.setLocation( "version", source.getLocation( "version" ) );
2317 }
2318 }
2319 }
2320
2321 protected void mergeBuildBase( BuildBase target, BuildBase source, boolean sourceDominant,
2322 Map<Object, Object> context )
2323 {
2324 mergePluginConfiguration( target, source, sourceDominant, context );
2325 mergeBuildBase_DefaultGoal( target, source, sourceDominant, context );
2326 mergeBuildBase_FinalName( target, source, sourceDominant, context );
2327 mergeBuildBase_Directory( target, source, sourceDominant, context );
2328 mergeBuildBase_Resources( target, source, sourceDominant, context );
2329 mergeBuildBase_TestResources( target, source, sourceDominant, context );
2330 mergeBuildBase_Filters( target, source, sourceDominant, context );
2331 }
2332
2333 protected void mergeBuildBase_DefaultGoal( BuildBase target, BuildBase source, boolean sourceDominant,
2334 Map<Object, Object> context )
2335 {
2336 String src = source.getDefaultGoal();
2337 if ( src != null )
2338 {
2339 if ( sourceDominant || target.getDefaultGoal() == null )
2340 {
2341 target.setDefaultGoal( src );
2342 target.setLocation( "defaultGoal", source.getLocation( "defaultGoal" ) );
2343 }
2344 }
2345 }
2346
2347 protected void mergeBuildBase_Directory( BuildBase target, BuildBase source, boolean sourceDominant,
2348 Map<Object, Object> context )
2349 {
2350 String src = source.getDirectory();
2351 if ( src != null )
2352 {
2353 if ( sourceDominant || target.getDirectory() == null )
2354 {
2355 target.setDirectory( src );
2356 target.setLocation( "directory", source.getLocation( "directory" ) );
2357 }
2358 }
2359 }
2360
2361 protected void mergeBuildBase_FinalName( BuildBase target, BuildBase source, boolean sourceDominant,
2362 Map<Object, Object> context )
2363 {
2364 String src = source.getFinalName();
2365 if ( src != null )
2366 {
2367 if ( sourceDominant || target.getFinalName() == null )
2368 {
2369 target.setFinalName( src );
2370 target.setLocation( "finalName", source.getLocation( "finalName" ) );
2371 }
2372 }
2373 }
2374
2375 protected void mergeBuildBase_Filters( BuildBase target, BuildBase source, boolean sourceDominant,
2376 Map<Object, Object> context )
2377 {
2378 List<String> src = source.getFilters();
2379 if ( !src.isEmpty() )
2380 {
2381 List<String> tgt = target.getFilters();
2382 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
2383 merged.addAll( tgt );
2384 merged.addAll( src );
2385 target.setFilters( merged );
2386 }
2387 }
2388
2389 protected void mergeBuildBase_Resources( BuildBase target, BuildBase source, boolean sourceDominant,
2390 Map<Object, Object> context )
2391 {
2392 List<Resource> src = source.getResources();
2393 if ( !src.isEmpty() )
2394 {
2395 List<Resource> tgt = target.getResources();
2396 Map<Object, Resource> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
2397
2398 for ( Resource element : tgt )
2399 {
2400 Object key = getResourceKey( element );
2401 merged.put( key, element );
2402 }
2403
2404 for ( Resource element : src )
2405 {
2406 Object key = getResourceKey( element );
2407 if ( sourceDominant || !merged.containsKey( key ) )
2408 {
2409 merged.put( key, element );
2410 }
2411 }
2412
2413 target.setResources( new ArrayList<>( merged.values() ) );
2414 }
2415 }
2416
2417 protected void mergeBuildBase_TestResources( BuildBase target, BuildBase source, boolean sourceDominant,
2418 Map<Object, Object> context )
2419 {
2420 List<Resource> src = source.getTestResources();
2421 if ( !src.isEmpty() )
2422 {
2423 List<Resource> tgt = target.getTestResources();
2424 Map<Object, Resource> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
2425
2426 for ( Resource element : tgt )
2427 {
2428 Object key = getResourceKey( element );
2429 merged.put( key, element );
2430 }
2431
2432 for ( Resource element : src )
2433 {
2434 Object key = getResourceKey( element );
2435 if ( sourceDominant || !merged.containsKey( key ) )
2436 {
2437 merged.put( key, element );
2438 }
2439 }
2440
2441 target.setTestResources( new ArrayList<>( merged.values() ) );
2442 }
2443 }
2444
2445 protected void mergePluginConfiguration( PluginConfiguration target, PluginConfiguration source,
2446 boolean sourceDominant, Map<Object, Object> context )
2447 {
2448 mergePluginContainer( target, source, sourceDominant, context );
2449 mergePluginConfiguration_PluginManagement( target, source, sourceDominant, context );
2450 }
2451
2452 protected void mergePluginConfiguration_PluginManagement( PluginConfiguration target, PluginConfiguration source,
2453 boolean sourceDominant, Map<Object, Object> context )
2454 {
2455 PluginManagement src = source.getPluginManagement();
2456 if ( src != null )
2457 {
2458 PluginManagement tgt = target.getPluginManagement();
2459 if ( tgt == null )
2460 {
2461 tgt = new PluginManagement();
2462 target.setPluginManagement( tgt );
2463 }
2464 mergePluginManagement( tgt, src, sourceDominant, context );
2465 }
2466 }
2467
2468 protected void mergePluginContainer( PluginContainer target, PluginContainer source, boolean sourceDominant,
2469 Map<Object, Object> context )
2470 {
2471 mergePluginContainer_Plugins( target, source, sourceDominant, context );
2472 }
2473
2474 protected void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source,
2475 boolean sourceDominant, Map<Object, Object> context )
2476 {
2477 List<Plugin> src = source.getPlugins();
2478 if ( !src.isEmpty() )
2479 {
2480 List<Plugin> tgt = target.getPlugins();
2481 Map<Object, Plugin> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
2482
2483 for ( Plugin element : tgt )
2484 {
2485 Object key = getPluginKey( element );
2486 merged.put( key, element );
2487 }
2488
2489 for ( Plugin element : src )
2490 {
2491 Object key = getPluginKey( element );
2492 if ( sourceDominant || !merged.containsKey( key ) )
2493 {
2494 merged.put( key, element );
2495 }
2496 }
2497
2498 target.setPlugins( new ArrayList<>( merged.values() ) );
2499 }
2500 }
2501
2502 protected void mergePluginManagement( PluginManagement target, PluginManagement source, boolean sourceDominant,
2503 Map<Object, Object> context )
2504 {
2505 mergePluginContainer( target, source, sourceDominant, context );
2506 }
2507
2508 protected void mergePlugin( Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2509 {
2510 mergeConfigurationContainer( target, source, sourceDominant, context );
2511 mergePlugin_GroupId( target, source, sourceDominant, context );
2512 mergePlugin_ArtifactId( target, source, sourceDominant, context );
2513 mergePlugin_Version( target, source, sourceDominant, context );
2514 mergePlugin_Extensions( target, source, sourceDominant, context );
2515 mergePlugin_Dependencies( target, source, sourceDominant, context );
2516 mergePlugin_Executions( target, source, sourceDominant, context );
2517 }
2518
2519 protected void mergePlugin_GroupId( Plugin target, Plugin source, boolean sourceDominant,
2520 Map<Object, Object> context )
2521 {
2522 String src = source.getGroupId();
2523 if ( src != null )
2524 {
2525 if ( sourceDominant || target.getGroupId() == null )
2526 {
2527 target.setGroupId( src );
2528 target.setLocation( "groupId", source.getLocation( "groupId" ) );
2529 }
2530 }
2531 }
2532
2533 protected void mergePlugin_ArtifactId( Plugin target, Plugin source, boolean sourceDominant,
2534 Map<Object, Object> context )
2535 {
2536 String src = source.getArtifactId();
2537 if ( src != null )
2538 {
2539 if ( sourceDominant || target.getArtifactId() == null )
2540 {
2541 target.setArtifactId( src );
2542 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
2543 }
2544 }
2545 }
2546
2547 protected void mergePlugin_Version( Plugin target, Plugin source, boolean sourceDominant,
2548 Map<Object, Object> context )
2549 {
2550 String src = source.getVersion();
2551 if ( src != null )
2552 {
2553 if ( sourceDominant || target.getVersion() == null )
2554 {
2555 target.setVersion( src );
2556 target.setLocation( "version", source.getLocation( "version" ) );
2557 }
2558 }
2559 }
2560
2561 protected void mergePlugin_Extensions( Plugin target, Plugin source, boolean sourceDominant,
2562 Map<Object, Object> context )
2563 {
2564 String src = source.getExtensions();
2565 if ( src != null )
2566 {
2567 if ( sourceDominant || target.getExtensions() == null )
2568 {
2569 target.setExtensions( src );
2570 target.setLocation( "extensions", source.getLocation( "extensions" ) );
2571 }
2572 }
2573 }
2574
2575 protected void mergePlugin_Dependencies( Plugin target, Plugin source, boolean sourceDominant,
2576 Map<Object, Object> context )
2577 {
2578 List<Dependency> src = source.getDependencies();
2579 if ( !src.isEmpty() )
2580 {
2581 List<Dependency> tgt = target.getDependencies();
2582 Map<Object, Dependency> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
2583
2584 for ( Dependency element : tgt )
2585 {
2586 Object key = getDependencyKey( element );
2587 merged.put( key, element );
2588 }
2589
2590 for ( Dependency element : src )
2591 {
2592 Object key = getDependencyKey( element );
2593 if ( sourceDominant || !merged.containsKey( key ) )
2594 {
2595 merged.put( key, element );
2596 }
2597 }
2598
2599 target.setDependencies( new ArrayList<>( merged.values() ) );
2600 }
2601 }
2602
2603 protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant,
2604 Map<Object, Object> context )
2605 {
2606 List<PluginExecution> src = source.getExecutions();
2607 if ( !src.isEmpty() )
2608 {
2609 List<PluginExecution> tgt = target.getExecutions();
2610
2611 Map<Object, PluginExecution> merged =
2612 new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
2613
2614 for ( PluginExecution element : tgt )
2615 {
2616 Object key = getPluginExecutionKey( element );
2617 merged.put( key, element );
2618 }
2619
2620 for ( PluginExecution element : src )
2621 {
2622 Object key = getPluginExecutionKey( element );
2623 if ( sourceDominant || !merged.containsKey( key ) )
2624 {
2625 merged.put( key, element );
2626 }
2627 }
2628
2629 target.setExecutions( new ArrayList<>( merged.values() ) );
2630 }
2631 }
2632
2633 protected void mergeConfigurationContainer( ConfigurationContainer target, ConfigurationContainer source,
2634 boolean sourceDominant, Map<Object, Object> context )
2635 {
2636 mergeConfigurationContainer_Inherited( target, source, sourceDominant, context );
2637 mergeConfigurationContainer_Configuration( target, source, sourceDominant, context );
2638 }
2639
2640 protected void mergeConfigurationContainer_Inherited( ConfigurationContainer target, ConfigurationContainer source,
2641 boolean sourceDominant, Map<Object, Object> context )
2642 {
2643 String src = source.getInherited();
2644 if ( src != null )
2645 {
2646 if ( sourceDominant || target.getInherited() == null )
2647 {
2648 target.setInherited( src );
2649 target.setLocation( "inherited", source.getLocation( "inherited" ) );
2650 }
2651 }
2652 }
2653
2654 protected void mergeConfigurationContainer_Configuration( ConfigurationContainer target,
2655 ConfigurationContainer source, boolean sourceDominant,
2656 Map<Object, Object> context )
2657 {
2658 Xpp3Dom src = (Xpp3Dom) source.getConfiguration();
2659 if ( src != null )
2660 {
2661 Xpp3Dom tgt = (Xpp3Dom) target.getConfiguration();
2662 if ( sourceDominant || tgt == null )
2663 {
2664 tgt = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( src ), tgt );
2665 }
2666 else
2667 {
2668 tgt = Xpp3Dom.mergeXpp3Dom( tgt, src );
2669 }
2670 target.setConfiguration( tgt );
2671 }
2672 }
2673
2674 protected void mergePluginExecution( PluginExecution target, PluginExecution source, boolean sourceDominant,
2675 Map<Object, Object> context )
2676 {
2677 mergeConfigurationContainer( target, source, sourceDominant, context );
2678 mergePluginExecution_Id( target, source, sourceDominant, context );
2679 mergePluginExecution_Phase( target, source, sourceDominant, context );
2680 mergePluginExecution_Goals( target, source, sourceDominant, context );
2681 }
2682
2683 protected void mergePluginExecution_Id( PluginExecution target, PluginExecution source, boolean sourceDominant,
2684 Map<Object, Object> context )
2685 {
2686 String src = source.getId();
2687 if ( src != null )
2688 {
2689 if ( sourceDominant || target.getId() == null )
2690 {
2691 target.setId( src );
2692 target.setLocation( "id", source.getLocation( "id" ) );
2693 }
2694 }
2695 }
2696
2697 protected void mergePluginExecution_Phase( PluginExecution target, PluginExecution source, boolean sourceDominant,
2698 Map<Object, Object> context )
2699 {
2700 String src = source.getPhase();
2701 if ( src != null )
2702 {
2703 if ( sourceDominant || target.getPhase() == null )
2704 {
2705 target.setPhase( src );
2706 target.setLocation( "phase", source.getLocation( "phase" ) );
2707 }
2708 }
2709 }
2710
2711 protected void mergePluginExecution_Goals( PluginExecution target, PluginExecution source, boolean sourceDominant,
2712 Map<Object, Object> context )
2713 {
2714 List<String> src = source.getGoals();
2715 if ( !src.isEmpty() )
2716 {
2717 List<String> tgt = target.getGoals();
2718 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
2719 merged.addAll( tgt );
2720 merged.addAll( src );
2721 target.setGoals( merged );
2722 }
2723 }
2724
2725 protected void mergeResource( Resource target, Resource source, boolean sourceDominant,
2726 Map<Object, Object> context )
2727 {
2728 mergeFileSet( target, source, sourceDominant, context );
2729 mergeResource_TargetPath( target, source, sourceDominant, context );
2730 mergeResource_Filtering( target, source, sourceDominant, context );
2731 mergeResource_MergeId( target, source, sourceDominant, context );
2732 }
2733
2734 protected void mergeResource_TargetPath( Resource target, Resource source, boolean sourceDominant,
2735 Map<Object, Object> context )
2736 {
2737 String src = source.getTargetPath();
2738 if ( src != null )
2739 {
2740 if ( sourceDominant || target.getTargetPath() == null )
2741 {
2742 target.setTargetPath( src );
2743 target.setLocation( "targetPath", source.getLocation( "targetPath" ) );
2744 }
2745 }
2746 }
2747
2748 protected void mergeResource_Filtering( Resource target, Resource source, boolean sourceDominant,
2749 Map<Object, Object> context )
2750 {
2751 String src = source.getFiltering();
2752 if ( src != null )
2753 {
2754 if ( sourceDominant || target.getFiltering() == null )
2755 {
2756 target.setFiltering( src );
2757 target.setLocation( "filtering", source.getLocation( "filtering" ) );
2758 }
2759 }
2760 }
2761
2762 protected void mergeResource_MergeId( Resource target, Resource source, boolean sourceDominant,
2763 Map<Object, Object> context )
2764 {
2765 String src = source.getMergeId();
2766 if ( src != null )
2767 {
2768 if ( sourceDominant || target.getMergeId() == null )
2769 {
2770 target.setMergeId( src );
2771 }
2772 }
2773 }
2774
2775 protected void mergeFileSet( FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context )
2776 {
2777 mergePatternSet( target, source, sourceDominant, context );
2778 mergeFileSet_Directory( target, source, sourceDominant, context );
2779 }
2780
2781 protected void mergeFileSet_Directory( FileSet target, FileSet source, boolean sourceDominant,
2782 Map<Object, Object> context )
2783 {
2784 String src = source.getDirectory();
2785 if ( src != null )
2786 {
2787 if ( sourceDominant || target.getDirectory() == null )
2788 {
2789 target.setDirectory( src );
2790 target.setLocation( "directory", source.getLocation( "directory" ) );
2791 }
2792 }
2793 }
2794
2795 protected void mergePatternSet( PatternSet target, PatternSet source, boolean sourceDominant,
2796 Map<Object, Object> context )
2797 {
2798 mergePatternSet_Includes( target, source, sourceDominant, context );
2799 mergePatternSet_Excludes( target, source, sourceDominant, context );
2800 }
2801
2802 protected void mergePatternSet_Includes( PatternSet target, PatternSet source, boolean sourceDominant,
2803 Map<Object, Object> context )
2804 {
2805 List<String> src = source.getIncludes();
2806 if ( !src.isEmpty() )
2807 {
2808 List<String> tgt = target.getIncludes();
2809 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
2810 merged.addAll( tgt );
2811 merged.addAll( src );
2812 target.setIncludes( merged );
2813 }
2814 }
2815
2816 protected void mergePatternSet_Excludes( PatternSet target, PatternSet source, boolean sourceDominant,
2817 Map<Object, Object> context )
2818 {
2819 List<String> src = source.getExcludes();
2820 if ( !src.isEmpty() )
2821 {
2822 List<String> tgt = target.getExcludes();
2823 List<String> merged = new ArrayList<>( tgt.size() + src.size() );
2824 merged.addAll( tgt );
2825 merged.addAll( src );
2826 target.setExcludes( merged );
2827 }
2828 }
2829
2830 protected void mergeProfile( Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2831 {
2832 mergeModelBase( target, source, sourceDominant, context );
2833
2834 }
2835
2836 protected void mergeActivation( Activation target, Activation source, boolean sourceDominant,
2837 Map<Object, Object> context )
2838 {
2839
2840 }
2841
2842 protected Object getDependencyKey( Dependency dependency )
2843 {
2844 return dependency;
2845 }
2846
2847 protected Object getPluginKey( Plugin plugin )
2848 {
2849 return plugin;
2850 }
2851
2852 protected Object getPluginExecutionKey( PluginExecution pluginExecution )
2853 {
2854 return pluginExecution;
2855 }
2856
2857 protected Object getReportPluginKey( ReportPlugin reportPlugin )
2858 {
2859 return reportPlugin;
2860 }
2861
2862 protected Object getReportSetKey( ReportSet reportSet )
2863 {
2864 return reportSet;
2865 }
2866
2867 protected Object getLicenseKey( License license )
2868 {
2869 return license;
2870 }
2871
2872 protected Object getMailingListKey( MailingList mailingList )
2873 {
2874 return mailingList;
2875 }
2876
2877 protected Object getDeveloperKey( Developer developer )
2878 {
2879 return developer;
2880 }
2881
2882 protected Object getContributorKey( Contributor contributor )
2883 {
2884 return contributor;
2885 }
2886
2887 protected Object getProfileKey( Profile profile )
2888 {
2889 return profile;
2890 }
2891
2892 protected Object getRepositoryKey( Repository repository )
2893 {
2894 return getRepositoryBaseKey( repository );
2895 }
2896
2897 protected Object getRepositoryBaseKey( RepositoryBase repositoryBase )
2898 {
2899 return repositoryBase;
2900 }
2901
2902 protected Object getNotifierKey( Notifier notifier )
2903 {
2904 return notifier;
2905 }
2906
2907 protected Object getResourceKey( Resource resource )
2908 {
2909 return resource;
2910 }
2911
2912 protected Object getExtensionKey( Extension extension )
2913 {
2914 return extension;
2915 }
2916
2917 protected Object getExclusionKey( Exclusion exclusion )
2918 {
2919 return exclusion;
2920 }
2921
2922 }