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