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 ( source.getParent() != 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 ( source.getOrganization() != 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 ( source.getIssueManagement() != 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 ( source.getScm() != 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 ( source.getCiManagement() != 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 ( source.getPrerequisites() != 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 ( source.getBuild() != 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 ( source.getDistributionManagement() != 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 ( source.getReporting() != 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 ( source.getDependencyManagement() != 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 mergeReportPlugin_Inherited( target, source, sourceDominant, context );
1324 mergeReportPlugin_Configuration( target, source, sourceDominant, context );
1325 mergeReportPlugin_GroupId( target, source, sourceDominant, context );
1326 mergeReportPlugin_ArtifactId( target, source, sourceDominant, context );
1327 mergeReportPlugin_Version( target, source, sourceDominant, context );
1328 mergeReportPlugin_ReportSets( target, source, sourceDominant, context );
1329 }
1330
1331 protected void mergeReportPlugin_GroupId( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1332 Map<Object, Object> context )
1333 {
1334 String src = source.getGroupId();
1335 if ( src != null )
1336 {
1337 if ( sourceDominant || target.getGroupId() == null )
1338 {
1339 target.setGroupId( src );
1340 target.setLocation( "groupId", source.getLocation( "groupId" ) );
1341 }
1342 }
1343 }
1344
1345 protected void mergeReportPlugin_ArtifactId( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1346 Map<Object, Object> context )
1347 {
1348 String src = source.getArtifactId();
1349 if ( src != null )
1350 {
1351 if ( sourceDominant || target.getArtifactId() == null )
1352 {
1353 target.setArtifactId( src );
1354 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
1355 }
1356 }
1357 }
1358
1359 protected void mergeReportPlugin_Version( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1360 Map<Object, Object> context )
1361 {
1362 String src = source.getVersion();
1363 if ( src != null )
1364 {
1365 if ( sourceDominant || target.getVersion() == null )
1366 {
1367 target.setVersion( src );
1368 target.setLocation( "version", source.getLocation( "version" ) );
1369 }
1370 }
1371 }
1372
1373 protected void mergeReportPlugin_Inherited( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1374 Map<Object, Object> context )
1375 {
1376 String src = source.getInherited();
1377 if ( src != null )
1378 {
1379 if ( sourceDominant || target.getInherited() == null )
1380 {
1381 target.setInherited( src );
1382 target.setLocation( "inherited", source.getLocation( "inherited" ) );
1383 }
1384 }
1385 }
1386
1387 protected void mergeReportPlugin_Configuration( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1388 Map<Object, Object> context )
1389 {
1390 Xpp3Dom src = (Xpp3Dom) source.getConfiguration();
1391 if ( src != null )
1392 {
1393 Xpp3Dom tgt = (Xpp3Dom) target.getConfiguration();
1394 if ( sourceDominant || tgt == null )
1395 {
1396 tgt = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( src ), tgt );
1397 }
1398 else
1399 {
1400 tgt = Xpp3Dom.mergeXpp3Dom( tgt, src );
1401 }
1402 target.setConfiguration( tgt );
1403 }
1404 }
1405
1406 protected void mergeReportPlugin_ReportSets( ReportPlugin target, ReportPlugin source, boolean sourceDominant,
1407 Map<Object, Object> context )
1408 {
1409 List<ReportSet> src = source.getReportSets();
1410 if ( !src.isEmpty() )
1411 {
1412 List<ReportSet> tgt = target.getReportSets();
1413 Map<Object, ReportSet> merged = new LinkedHashMap<Object, ReportSet>( ( src.size() + tgt.size() ) * 2 );
1414
1415 for ( ReportSet element : tgt )
1416 {
1417 Object key = getReportSetKey( element );
1418 merged.put( key, element );
1419 }
1420
1421 for ( ReportSet element : src )
1422 {
1423 Object key = getReportSetKey( element );
1424 if ( sourceDominant || !merged.containsKey( key ) )
1425 {
1426 merged.put( key, element );
1427 }
1428 }
1429
1430 target.setReportSets( new ArrayList<ReportSet>( merged.values() ) );
1431 }
1432 }
1433
1434 protected void mergeDependencyManagement( DependencyManagement target, DependencyManagement source,
1435 boolean sourceDominant, Map<Object, Object> context )
1436 {
1437 mergeDependencyManagement_Dependencies( target, source, sourceDominant, context );
1438 }
1439
1440 protected void mergeDependencyManagement_Dependencies( DependencyManagement target, DependencyManagement source,
1441 boolean sourceDominant, Map<Object, Object> context )
1442 {
1443 List<Dependency> src = source.getDependencies();
1444 if ( !src.isEmpty() )
1445 {
1446 List<Dependency> tgt = target.getDependencies();
1447 Map<Object, Dependency> merged = new LinkedHashMap<Object, Dependency>( ( src.size() + tgt.size() ) * 2 );
1448
1449 for ( Dependency element : tgt )
1450 {
1451 Object key = getDependencyKey( element );
1452 merged.put( key, element );
1453 }
1454
1455 for ( Dependency element : src )
1456 {
1457 Object key = getDependencyKey( element );
1458 if ( sourceDominant || !merged.containsKey( key ) )
1459 {
1460 merged.put( key, element );
1461 }
1462 }
1463
1464 target.setDependencies( new ArrayList<Dependency>( merged.values() ) );
1465 }
1466 }
1467
1468 protected void mergeParent( Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1469 {
1470 mergeParent_GroupId( target, source, sourceDominant, context );
1471 mergeParent_ArtifactId( target, source, sourceDominant, context );
1472 mergeParent_Version( target, source, sourceDominant, context );
1473 mergeParent_RelativePath( target, source, sourceDominant, context );
1474 }
1475
1476 protected void mergeParent_GroupId( Parent target, Parent source, boolean sourceDominant,
1477 Map<Object, Object> context )
1478 {
1479 String src = source.getGroupId();
1480 if ( src != null )
1481 {
1482 if ( sourceDominant || target.getGroupId() == null )
1483 {
1484 target.setGroupId( src );
1485 target.setLocation( "groupId", source.getLocation( "groupId" ) );
1486 }
1487 }
1488 }
1489
1490 protected void mergeParent_ArtifactId( Parent target, Parent source, boolean sourceDominant,
1491 Map<Object, Object> context )
1492 {
1493 String src = source.getArtifactId();
1494 if ( src != null )
1495 {
1496 if ( sourceDominant || target.getArtifactId() == null )
1497 {
1498 target.setArtifactId( src );
1499 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
1500 }
1501 }
1502 }
1503
1504 protected void mergeParent_Version( Parent target, Parent source, boolean sourceDominant,
1505 Map<Object, Object> context )
1506 {
1507 String src = source.getVersion();
1508 if ( src != null )
1509 {
1510 if ( sourceDominant || target.getVersion() == null )
1511 {
1512 target.setVersion( src );
1513 target.setLocation( "version", source.getLocation( "version" ) );
1514 }
1515 }
1516 }
1517
1518 protected void mergeParent_RelativePath( Parent target, Parent source, boolean sourceDominant,
1519 Map<Object, Object> context )
1520 {
1521 String src = source.getRelativePath();
1522 if ( src != null )
1523 {
1524 if ( sourceDominant || target.getRelativePath() == null )
1525 {
1526 target.setRelativePath( src );
1527 target.setLocation( "relativePath", source.getLocation( "relativePath" ) );
1528 }
1529 }
1530 }
1531
1532 protected void mergeOrganization( Organization target, Organization source, boolean sourceDominant,
1533 Map<Object, Object> context )
1534 {
1535 mergeOrganization_Name( target, source, sourceDominant, context );
1536 mergeOrganization_Url( target, source, sourceDominant, context );
1537 }
1538
1539 protected void mergeOrganization_Name( Organization target, Organization source, boolean sourceDominant,
1540 Map<Object, Object> context )
1541 {
1542 String src = source.getName();
1543 if ( src != null )
1544 {
1545 if ( sourceDominant || target.getName() == null )
1546 {
1547 target.setName( src );
1548 target.setLocation( "name", source.getLocation( "name" ) );
1549 }
1550 }
1551 }
1552
1553 protected void mergeOrganization_Url( Organization target, Organization source, boolean sourceDominant,
1554 Map<Object, Object> context )
1555 {
1556 String src = source.getUrl();
1557 if ( src != null )
1558 {
1559 if ( sourceDominant || target.getUrl() == null )
1560 {
1561 target.setUrl( src );
1562 target.setLocation( "url", source.getLocation( "url" ) );
1563 }
1564 }
1565 }
1566
1567 protected void mergeLicense( License target, License source, boolean sourceDominant, Map<Object, Object> context )
1568 {
1569 mergeLicense_Name( target, source, sourceDominant, context );
1570 mergeLicense_Url( target, source, sourceDominant, context );
1571 mergeLicense_Distribution( target, source, sourceDominant, context );
1572 mergeLicense_Comments( target, source, sourceDominant, context );
1573 }
1574
1575 protected void mergeLicense_Name( License target, License source, boolean sourceDominant,
1576 Map<Object, Object> context )
1577 {
1578 String src = source.getName();
1579 if ( src != null )
1580 {
1581 if ( sourceDominant || target.getName() == null )
1582 {
1583 target.setName( src );
1584 target.setLocation( "name", source.getLocation( "name" ) );
1585 }
1586 }
1587 }
1588
1589 protected void mergeLicense_Url( License target, License source, boolean sourceDominant,
1590 Map<Object, Object> context )
1591 {
1592 String src = source.getUrl();
1593 if ( src != null )
1594 {
1595 if ( sourceDominant || target.getUrl() == null )
1596 {
1597 target.setUrl( src );
1598 target.setLocation( "url", source.getLocation( "url" ) );
1599 }
1600 }
1601 }
1602
1603 protected void mergeLicense_Distribution( License target, License source, boolean sourceDominant,
1604 Map<Object, Object> context )
1605 {
1606 String src = source.getDistribution();
1607 if ( src != null )
1608 {
1609 if ( sourceDominant || target.getDistribution() == null )
1610 {
1611 target.setDistribution( src );
1612 target.setLocation( "distribution", source.getLocation( "distribution" ) );
1613 }
1614 }
1615 }
1616
1617 protected void mergeLicense_Comments( License target, License source, boolean sourceDominant,
1618 Map<Object, Object> context )
1619 {
1620 String src = source.getComments();
1621 if ( src != null )
1622 {
1623 if ( sourceDominant || target.getComments() == null )
1624 {
1625 target.setComments( src );
1626 target.setLocation( "comments", source.getLocation( "comments" ) );
1627 }
1628 }
1629 }
1630
1631 protected void mergeMailingList( MailingList target, MailingList source, boolean sourceDominant,
1632 Map<Object, Object> context )
1633 {
1634 mergeMailingList_Name( target, source, sourceDominant, context );
1635 mergeMailingList_Subscribe( target, source, sourceDominant, context );
1636 mergeMailingList_Unsubscribe( target, source, sourceDominant, context );
1637 mergeMailingList_Post( target, source, sourceDominant, context );
1638 mergeMailingList_OtherArchives( target, source, sourceDominant, context );
1639 }
1640
1641 protected void mergeMailingList_Name( MailingList target, MailingList source, boolean sourceDominant,
1642 Map<Object, Object> context )
1643 {
1644 String src = source.getName();
1645 if ( src != null )
1646 {
1647 if ( sourceDominant || target.getName() == null )
1648 {
1649 target.setName( src );
1650 target.setLocation( "name", source.getLocation( "name" ) );
1651 }
1652 }
1653 }
1654
1655 protected void mergeMailingList_Subscribe( MailingList target, MailingList source, boolean sourceDominant,
1656 Map<Object, Object> context )
1657 {
1658 String src = source.getSubscribe();
1659 if ( src != null )
1660 {
1661 if ( sourceDominant || target.getSubscribe() == null )
1662 {
1663 target.setSubscribe( src );
1664 target.setLocation( "subscribe", source.getLocation( "subscribe" ) );
1665 }
1666 }
1667 }
1668
1669 protected void mergeMailingList_Unsubscribe( MailingList target, MailingList source, boolean sourceDominant,
1670 Map<Object, Object> context )
1671 {
1672 String src = source.getUnsubscribe();
1673 if ( src != null )
1674 {
1675 if ( sourceDominant || target.getUnsubscribe() == null )
1676 {
1677 target.setUnsubscribe( src );
1678 target.setLocation( "unsubscribe", source.getLocation( "unsubscribe" ) );
1679 }
1680 }
1681 }
1682
1683 protected void mergeMailingList_Post( MailingList target, MailingList source, boolean sourceDominant,
1684 Map<Object, Object> context )
1685 {
1686 String src = source.getPost();
1687 if ( src != null )
1688 {
1689 if ( sourceDominant || target.getPost() == null )
1690 {
1691 target.setPost( src );
1692 target.setLocation( "post", source.getLocation( "post" ) );
1693 }
1694 }
1695 }
1696
1697 protected void mergeMailingList_Archive( MailingList target, MailingList source, boolean sourceDominant,
1698 Map<Object, Object> context )
1699 {
1700 String src = source.getArchive();
1701 if ( src != null )
1702 {
1703 if ( sourceDominant || target.getArchive() == null )
1704 {
1705 target.setArchive( src );
1706 target.setLocation( "archive", source.getLocation( "archive" ) );
1707 }
1708 }
1709 }
1710
1711 protected void mergeMailingList_OtherArchives( MailingList target, MailingList source, boolean sourceDominant,
1712 Map<Object, Object> context )
1713 {
1714 List<String> src = source.getOtherArchives();
1715 if ( !src.isEmpty() )
1716 {
1717 List<String> tgt = target.getOtherArchives();
1718 List<String> merged = new ArrayList<String>( tgt.size() + src.size() );
1719 merged.addAll( tgt );
1720 merged.addAll( src );
1721 target.setOtherArchives( merged );
1722 }
1723 }
1724
1725 protected void mergeDeveloper( Developer target, Developer source, boolean sourceDominant,
1726 Map<Object, Object> context )
1727 {
1728 mergeContributor( target, source, sourceDominant, context );
1729 mergeDeveloper_Id( target, source, sourceDominant, context );
1730 }
1731
1732 protected void mergeDeveloper_Id( Developer target, Developer source, boolean sourceDominant,
1733 Map<Object, Object> context )
1734 {
1735 String src = source.getId();
1736 if ( src != null )
1737 {
1738 if ( sourceDominant || target.getId() == null )
1739 {
1740 target.setId( src );
1741 target.setLocation( "id", source.getLocation( "id" ) );
1742 }
1743 }
1744 }
1745
1746 protected void mergeContributor( Contributor target, Contributor source, boolean sourceDominant,
1747 Map<Object, Object> context )
1748 {
1749 mergeContributor_Name( target, source, sourceDominant, context );
1750 mergeContributor_Email( target, source, sourceDominant, context );
1751 mergeContributor_Url( target, source, sourceDominant, context );
1752 mergeContributor_Organization( target, source, sourceDominant, context );
1753 mergeContributor_OrganizationUrl( target, source, sourceDominant, context );
1754 mergeContributor_Timezone( target, source, sourceDominant, context );
1755 mergeContributor_Roles( target, source, sourceDominant, context );
1756 mergeContributor_Properties( target, source, sourceDominant, context );
1757 }
1758
1759 protected void mergeContributor_Name( Contributor target, Contributor source, boolean sourceDominant,
1760 Map<Object, Object> context )
1761 {
1762 String src = source.getName();
1763 if ( src != null )
1764 {
1765 if ( sourceDominant || target.getName() == null )
1766 {
1767 target.setName( src );
1768 target.setLocation( "name", source.getLocation( "name" ) );
1769 }
1770 }
1771 }
1772
1773 protected void mergeContributor_Email( Contributor target, Contributor source, boolean sourceDominant,
1774 Map<Object, Object> context )
1775 {
1776 String src = source.getEmail();
1777 if ( src != null )
1778 {
1779 if ( sourceDominant || target.getEmail() == null )
1780 {
1781 target.setEmail( src );
1782 target.setLocation( "email", source.getLocation( "email" ) );
1783 }
1784 }
1785 }
1786
1787 protected void mergeContributor_Url( Contributor target, Contributor source, boolean sourceDominant,
1788 Map<Object, Object> context )
1789 {
1790 String src = source.getUrl();
1791 if ( src != null )
1792 {
1793 if ( sourceDominant || target.getUrl() == null )
1794 {
1795 target.setUrl( src );
1796 target.setLocation( "url", source.getLocation( "url" ) );
1797 }
1798 }
1799 }
1800
1801 protected void mergeContributor_Organization( Contributor target, Contributor source, boolean sourceDominant,
1802 Map<Object, Object> context )
1803 {
1804 String src = source.getOrganization();
1805 if ( src != null )
1806 {
1807 if ( sourceDominant || target.getOrganization() == null )
1808 {
1809 target.setOrganization( src );
1810 target.setLocation( "organization", source.getLocation( "organization" ) );
1811 }
1812 }
1813 }
1814
1815 protected void mergeContributor_OrganizationUrl( Contributor target, Contributor source, boolean sourceDominant,
1816 Map<Object, Object> context )
1817 {
1818 String src = source.getOrganizationUrl();
1819 if ( src != null )
1820 {
1821 if ( sourceDominant || target.getOrganizationUrl() == null )
1822 {
1823 target.setOrganizationUrl( src );
1824 target.setLocation( "organizationUrl", source.getLocation( "organizationUrl" ) );
1825 }
1826 }
1827 }
1828
1829 protected void mergeContributor_Timezone( Contributor target, Contributor source, boolean sourceDominant,
1830 Map<Object, Object> context )
1831 {
1832 String src = source.getTimezone();
1833 if ( src != null )
1834 {
1835 if ( sourceDominant || target.getTimezone() == null )
1836 {
1837 target.setTimezone( src );
1838 target.setLocation( "timezone", source.getLocation( "timezone" ) );
1839 }
1840 }
1841 }
1842
1843 protected void mergeContributor_Roles( Contributor target, Contributor source, boolean sourceDominant,
1844 Map<Object, Object> context )
1845 {
1846 List<String> src = source.getRoles();
1847 if ( !src.isEmpty() )
1848 {
1849 List<String> tgt = target.getRoles();
1850 List<String> merged = new ArrayList<String>( tgt.size() + src.size() );
1851 merged.addAll( tgt );
1852 merged.addAll( src );
1853 target.setRoles( merged );
1854 }
1855 }
1856
1857 protected void mergeContributor_Properties( Contributor target, Contributor source, boolean sourceDominant,
1858 Map<Object, Object> context )
1859 {
1860 Properties merged = new Properties();
1861 if ( sourceDominant )
1862 {
1863 merged.putAll( target.getProperties() );
1864 merged.putAll( source.getProperties() );
1865 }
1866 else
1867 {
1868 merged.putAll( source.getProperties() );
1869 merged.putAll( target.getProperties() );
1870 }
1871 target.setProperties( merged );
1872 target.setLocation( "properties", InputLocation.merge( target.getLocation( "properties" ),
1873 source.getLocation( "properties" ), sourceDominant ) );
1874 }
1875
1876 protected void mergeIssueManagement( IssueManagement target, IssueManagement source, boolean sourceDominant,
1877 Map<Object, Object> context )
1878 {
1879 mergeIssueManagement_Url( target, source, sourceDominant, context );
1880 mergeIssueManagement_System( target, source, sourceDominant, context );
1881 }
1882
1883 protected void mergeIssueManagement_System( IssueManagement target, IssueManagement source, boolean sourceDominant,
1884 Map<Object, Object> context )
1885 {
1886 String src = source.getSystem();
1887 if ( src != null )
1888 {
1889 if ( sourceDominant || target.getSystem() == null )
1890 {
1891 target.setSystem( src );
1892 target.setLocation( "system", source.getLocation( "system" ) );
1893 }
1894 }
1895 }
1896
1897 protected void mergeIssueManagement_Url( IssueManagement target, IssueManagement source, boolean sourceDominant,
1898 Map<Object, Object> context )
1899 {
1900 String src = source.getUrl();
1901 if ( src != null )
1902 {
1903 if ( sourceDominant || target.getUrl() == null )
1904 {
1905 target.setUrl( src );
1906 target.setLocation( "url", source.getLocation( "url" ) );
1907 }
1908 }
1909 }
1910
1911 protected void mergeScm( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1912 {
1913 mergeScm_Url( target, source, sourceDominant, context );
1914 mergeScm_Connection( target, source, sourceDominant, context );
1915 mergeScm_DeveloperConnection( target, source, sourceDominant, context );
1916 mergeScm_Tag( target, source, sourceDominant, context );
1917 }
1918
1919 protected void mergeScm_Url( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1920 {
1921 String src = source.getUrl();
1922 if ( src != null )
1923 {
1924 if ( sourceDominant || target.getUrl() == null )
1925 {
1926 target.setUrl( src );
1927 target.setLocation( "url", source.getLocation( "url" ) );
1928 }
1929 }
1930 }
1931
1932 protected void mergeScm_Connection( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1933 {
1934 String src = source.getConnection();
1935 if ( src != null )
1936 {
1937 if ( sourceDominant || target.getConnection() == null )
1938 {
1939 target.setConnection( src );
1940 target.setLocation( "connection", source.getLocation( "connection" ) );
1941 }
1942 }
1943 }
1944
1945 protected void mergeScm_DeveloperConnection( Scm target, Scm source, boolean sourceDominant,
1946 Map<Object, Object> context )
1947 {
1948 String src = source.getDeveloperConnection();
1949 if ( src != null )
1950 {
1951 if ( sourceDominant || target.getDeveloperConnection() == null )
1952 {
1953 target.setDeveloperConnection( src );
1954 target.setLocation( "developerConnection", source.getLocation( "developerConnection" ) );
1955 }
1956 }
1957 }
1958
1959 protected void mergeScm_Tag( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1960 {
1961 String src = source.getTag();
1962 if ( src != null )
1963 {
1964 if ( sourceDominant || target.getTag() == null )
1965 {
1966 target.setTag( src );
1967 target.setLocation( "tag", source.getLocation( "tag" ) );
1968 }
1969 }
1970 }
1971
1972 protected void mergeCiManagement( CiManagement target, CiManagement source, boolean sourceDominant,
1973 Map<Object, Object> context )
1974 {
1975 mergeCiManagement_System( target, source, sourceDominant, context );
1976 mergeCiManagement_Url( target, source, sourceDominant, context );
1977 mergeCiManagement_Notifiers( target, source, sourceDominant, context );
1978 }
1979
1980 protected void mergeCiManagement_System( CiManagement target, CiManagement source, boolean sourceDominant,
1981 Map<Object, Object> context )
1982 {
1983 String src = source.getSystem();
1984 if ( src != null )
1985 {
1986 if ( sourceDominant || target.getSystem() == null )
1987 {
1988 target.setSystem( src );
1989 target.setLocation( "system", source.getLocation( "system" ) );
1990 }
1991 }
1992 }
1993
1994 protected void mergeCiManagement_Url( CiManagement target, CiManagement source, boolean sourceDominant,
1995 Map<Object, Object> context )
1996 {
1997 String src = source.getUrl();
1998 if ( src != null )
1999 {
2000 if ( sourceDominant || target.getUrl() == null )
2001 {
2002 target.setUrl( src );
2003 target.setLocation( "url", source.getLocation( "url" ) );
2004 }
2005 }
2006 }
2007
2008 protected void mergeCiManagement_Notifiers( CiManagement target, CiManagement source, boolean sourceDominant,
2009 Map<Object, Object> context )
2010 {
2011 List<Notifier> src = source.getNotifiers();
2012 if ( !src.isEmpty() )
2013 {
2014 List<Notifier> tgt = target.getNotifiers();
2015 Map<Object, Notifier> merged = new LinkedHashMap<Object, Notifier>( ( src.size() + tgt.size() ) * 2 );
2016
2017 for ( Notifier element : tgt )
2018 {
2019 Object key = getNotifierKey( element );
2020 merged.put( key, element );
2021 }
2022
2023 for ( Notifier element : src )
2024 {
2025 Object key = getNotifierKey( element );
2026 if ( sourceDominant || !merged.containsKey( key ) )
2027 {
2028 merged.put( key, element );
2029 }
2030 }
2031
2032 target.setNotifiers( new ArrayList<Notifier>( merged.values() ) );
2033 }
2034 }
2035
2036 protected void mergeNotifier( Notifier target, Notifier source, boolean sourceDominant,
2037 Map<Object, Object> context )
2038 {
2039 mergeNotifier_Type( target, source, sourceDominant, context );
2040 mergeNotifier_Address( target, source, sourceDominant, context );
2041 mergeNotifier_Configuration( target, source, sourceDominant, context );
2042 mergeNotifier_SendOnError( target, source, sourceDominant, context );
2043 mergeNotifier_SendOnFailure( target, source, sourceDominant, context );
2044 mergeNotifier_SendOnSuccess( target, source, sourceDominant, context );
2045 mergeNotifier_SendOnWarning( target, source, sourceDominant, context );
2046 }
2047
2048 protected void mergeNotifier_Type( Notifier target, Notifier source, boolean sourceDominant,
2049 Map<Object, Object> context )
2050 {
2051 String src = source.getType();
2052 if ( src != null )
2053 {
2054 if ( sourceDominant || target.getType() == null )
2055 {
2056 target.setType( src );
2057 }
2058 }
2059 }
2060
2061 protected void mergeNotifier_Address( Notifier target, Notifier source, boolean sourceDominant,
2062 Map<Object, Object> context )
2063 {
2064 String src = source.getAddress();
2065 if ( src != null )
2066 {
2067 if ( sourceDominant || target.getAddress() == null )
2068 {
2069 target.setAddress( src );
2070 }
2071 }
2072 }
2073
2074 protected void mergeNotifier_Configuration( Notifier target, Notifier source, boolean sourceDominant,
2075 Map<Object, Object> context )
2076 {
2077 Properties merged = new Properties();
2078 if ( sourceDominant )
2079 {
2080 merged.putAll( target.getConfiguration() );
2081 merged.putAll( source.getConfiguration() );
2082 }
2083 else
2084 {
2085 merged.putAll( source.getConfiguration() );
2086 merged.putAll( target.getConfiguration() );
2087 }
2088 target.setConfiguration( merged );
2089 }
2090
2091 protected void mergeNotifier_SendOnError( Notifier target, Notifier source, boolean sourceDominant,
2092 Map<Object, Object> context )
2093 {
2094 if ( sourceDominant )
2095 {
2096 target.setSendOnError( source.isSendOnError() );
2097 }
2098 }
2099
2100 protected void mergeNotifier_SendOnFailure( Notifier target, Notifier source, boolean sourceDominant,
2101 Map<Object, Object> context )
2102 {
2103 if ( sourceDominant )
2104 {
2105 target.setSendOnFailure( source.isSendOnFailure() );
2106 }
2107 }
2108
2109 protected void mergeNotifier_SendOnSuccess( Notifier target, Notifier source, boolean sourceDominant,
2110 Map<Object, Object> context )
2111 {
2112 if ( sourceDominant )
2113 {
2114 target.setSendOnSuccess( source.isSendOnSuccess() );
2115 }
2116 }
2117
2118 protected void mergeNotifier_SendOnWarning( Notifier target, Notifier source, boolean sourceDominant,
2119 Map<Object, Object> context )
2120 {
2121 if ( sourceDominant )
2122 {
2123 target.setSendOnWarning( source.isSendOnWarning() );
2124 }
2125 }
2126
2127 protected void mergePrerequisites( Prerequisites target, Prerequisites source, boolean sourceDominant,
2128 Map<Object, Object> context )
2129 {
2130 mergePrerequisites_Maven( target, source, sourceDominant, context );
2131 }
2132
2133 protected void mergePrerequisites_Maven( Prerequisites target, Prerequisites source, boolean sourceDominant,
2134 Map<Object, Object> context )
2135 {
2136 String src = source.getMaven();
2137 if ( src != null )
2138 {
2139 if ( sourceDominant || target.getMaven() == null )
2140 {
2141 target.setMaven( src );
2142 target.setLocation( "maven", source.getLocation( "maven" ) );
2143 }
2144 }
2145 }
2146
2147 protected void mergeBuild( Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
2148 {
2149 mergeBuildBase( target, source, sourceDominant, context );
2150 mergeBuild_SourceDirectory( target, source, sourceDominant, context );
2151 mergeBuild_ScriptSourceDirectory( target, source, sourceDominant, context );
2152 mergeBuild_TestSourceDirectory( target, source, sourceDominant, context );
2153 mergeBuild_OutputDirectory( target, source, sourceDominant, context );
2154 mergeBuild_TestOutputDirectory( target, source, sourceDominant, context );
2155 mergeBuild_Extensions( target, source, sourceDominant, context );
2156 }
2157
2158 protected void mergeBuild_SourceDirectory( Build target, Build source, boolean sourceDominant,
2159 Map<Object, Object> context )
2160 {
2161 String src = source.getSourceDirectory();
2162 if ( src != null )
2163 {
2164 if ( sourceDominant || target.getSourceDirectory() == null )
2165 {
2166 target.setSourceDirectory( src );
2167 target.setLocation( "sourceDirectory", source.getLocation( "sourceDirectory" ) );
2168 }
2169 }
2170 }
2171
2172 protected void mergeBuild_ScriptSourceDirectory( Build target, Build source, boolean sourceDominant,
2173 Map<Object, Object> context )
2174 {
2175 String src = source.getScriptSourceDirectory();
2176 if ( src != null )
2177 {
2178 if ( sourceDominant || target.getScriptSourceDirectory() == null )
2179 {
2180 target.setScriptSourceDirectory( src );
2181 target.setLocation( "scriptSourceDirectory", source.getLocation( "scriptSourceDirectory" ) );
2182 }
2183 }
2184 }
2185
2186 protected void mergeBuild_TestSourceDirectory( Build target, Build source, boolean sourceDominant,
2187 Map<Object, Object> context )
2188 {
2189 String src = source.getTestSourceDirectory();
2190 if ( src != null )
2191 {
2192 if ( sourceDominant || target.getTestSourceDirectory() == null )
2193 {
2194 target.setTestSourceDirectory( src );
2195 target.setLocation( "testSourceDirectory", source.getLocation( "testSourceDirectory" ) );
2196 }
2197 }
2198 }
2199
2200 protected void mergeBuild_OutputDirectory( Build target, Build source, boolean sourceDominant,
2201 Map<Object, Object> context )
2202 {
2203 String src = source.getOutputDirectory();
2204 if ( src != null )
2205 {
2206 if ( sourceDominant || target.getOutputDirectory() == null )
2207 {
2208 target.setOutputDirectory( src );
2209 target.setLocation( "outputDirectory", source.getLocation( "outputDirectory" ) );
2210 }
2211 }
2212 }
2213
2214 protected void mergeBuild_TestOutputDirectory( Build target, Build source, boolean sourceDominant,
2215 Map<Object, Object> context )
2216 {
2217 String src = source.getTestOutputDirectory();
2218 if ( src != null )
2219 {
2220 if ( sourceDominant || target.getTestOutputDirectory() == null )
2221 {
2222 target.setTestOutputDirectory( src );
2223 target.setLocation( "testOutputDirectory", source.getLocation( "testOutputDirectory" ) );
2224 }
2225 }
2226 }
2227
2228 protected void mergeBuild_Extensions( Build target, Build source, boolean sourceDominant,
2229 Map<Object, Object> context )
2230 {
2231 List<Extension> src = source.getExtensions();
2232 if ( !src.isEmpty() )
2233 {
2234 List<Extension> tgt = target.getExtensions();
2235 Map<Object, Extension> merged = new LinkedHashMap<Object, Extension>( ( src.size() + tgt.size() ) * 2 );
2236
2237 for ( Extension element : tgt )
2238 {
2239 Object key = getExtensionKey( element );
2240 merged.put( key, element );
2241 }
2242
2243 for ( Extension element : src )
2244 {
2245 Object key = getExtensionKey( element );
2246 if ( sourceDominant || !merged.containsKey( key ) )
2247 {
2248 merged.put( key, element );
2249 }
2250 }
2251
2252 target.setExtensions( new ArrayList<Extension>( merged.values() ) );
2253 }
2254 }
2255
2256 protected void mergeExtension( Extension target, Extension source, boolean sourceDominant,
2257 Map<Object, Object> context )
2258 {
2259 mergeExtension_GroupId( target, source, sourceDominant, context );
2260 mergeExtension_ArtifactId( target, source, sourceDominant, context );
2261 mergeExtension_Version( target, source, sourceDominant, context );
2262 }
2263
2264 protected void mergeExtension_GroupId( Extension target, Extension source, boolean sourceDominant,
2265 Map<Object, Object> context )
2266 {
2267 String src = source.getGroupId();
2268 if ( src != null )
2269 {
2270 if ( sourceDominant || target.getGroupId() == null )
2271 {
2272 target.setGroupId( src );
2273 target.setLocation( "groupId", source.getLocation( "groupId" ) );
2274 }
2275 }
2276 }
2277
2278 protected void mergeExtension_ArtifactId( Extension target, Extension source, boolean sourceDominant,
2279 Map<Object, Object> context )
2280 {
2281 String src = source.getArtifactId();
2282 if ( src != null )
2283 {
2284 if ( sourceDominant || target.getArtifactId() == null )
2285 {
2286 target.setArtifactId( src );
2287 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
2288 }
2289 }
2290 }
2291
2292 protected void mergeExtension_Version( Extension target, Extension source, boolean sourceDominant,
2293 Map<Object, Object> context )
2294 {
2295 String src = source.getVersion();
2296 if ( src != null )
2297 {
2298 if ( sourceDominant || target.getVersion() == null )
2299 {
2300 target.setVersion( src );
2301 target.setLocation( "version", source.getLocation( "version" ) );
2302 }
2303 }
2304 }
2305
2306 protected void mergeBuildBase( BuildBase target, BuildBase source, boolean sourceDominant,
2307 Map<Object, Object> context )
2308 {
2309 mergePluginConfiguration( target, source, sourceDominant, context );
2310 mergeBuildBase_DefaultGoal( target, source, sourceDominant, context );
2311 mergeBuildBase_FinalName( target, source, sourceDominant, context );
2312 mergeBuildBase_Directory( target, source, sourceDominant, context );
2313 mergeBuildBase_Resources( target, source, sourceDominant, context );
2314 mergeBuildBase_TestResources( target, source, sourceDominant, context );
2315 mergeBuildBase_Filters( target, source, sourceDominant, context );
2316 }
2317
2318 protected void mergeBuildBase_DefaultGoal( BuildBase target, BuildBase source, boolean sourceDominant,
2319 Map<Object, Object> context )
2320 {
2321 String src = source.getDefaultGoal();
2322 if ( src != null )
2323 {
2324 if ( sourceDominant || target.getDefaultGoal() == null )
2325 {
2326 target.setDefaultGoal( src );
2327 target.setLocation( "defaultGoal", source.getLocation( "defaultGoal" ) );
2328 }
2329 }
2330 }
2331
2332 protected void mergeBuildBase_Directory( BuildBase target, BuildBase source, boolean sourceDominant,
2333 Map<Object, Object> context )
2334 {
2335 String src = source.getDirectory();
2336 if ( src != null )
2337 {
2338 if ( sourceDominant || target.getDirectory() == null )
2339 {
2340 target.setDirectory( src );
2341 target.setLocation( "directory", source.getLocation( "directory" ) );
2342 }
2343 }
2344 }
2345
2346 protected void mergeBuildBase_FinalName( BuildBase target, BuildBase source, boolean sourceDominant,
2347 Map<Object, Object> context )
2348 {
2349 String src = source.getFinalName();
2350 if ( src != null )
2351 {
2352 if ( sourceDominant || target.getFinalName() == null )
2353 {
2354 target.setFinalName( src );
2355 target.setLocation( "finalName", source.getLocation( "finalName" ) );
2356 }
2357 }
2358 }
2359
2360 protected void mergeBuildBase_Filters( BuildBase target, BuildBase source, boolean sourceDominant,
2361 Map<Object, Object> context )
2362 {
2363 List<String> src = source.getFilters();
2364 if ( !src.isEmpty() )
2365 {
2366 List<String> tgt = target.getFilters();
2367 List<String> merged = new ArrayList<String>( tgt.size() + src.size() );
2368 merged.addAll( tgt );
2369 merged.addAll( src );
2370 target.setFilters( merged );
2371 }
2372 }
2373
2374 protected void mergeBuildBase_Resources( BuildBase target, BuildBase source, boolean sourceDominant,
2375 Map<Object, Object> context )
2376 {
2377 List<Resource> src = source.getResources();
2378 if ( !src.isEmpty() )
2379 {
2380 List<Resource> tgt = target.getResources();
2381 Map<Object, Resource> merged = new LinkedHashMap<Object, Resource>( ( src.size() + tgt.size() ) * 2 );
2382
2383 for ( Resource element : tgt )
2384 {
2385 Object key = getResourceKey( element );
2386 merged.put( key, element );
2387 }
2388
2389 for ( Resource element : src )
2390 {
2391 Object key = getResourceKey( element );
2392 if ( sourceDominant || !merged.containsKey( key ) )
2393 {
2394 merged.put( key, element );
2395 }
2396 }
2397
2398 target.setResources( new ArrayList<Resource>( merged.values() ) );
2399 }
2400 }
2401
2402 protected void mergeBuildBase_TestResources( BuildBase target, BuildBase source, boolean sourceDominant,
2403 Map<Object, Object> context )
2404 {
2405 List<Resource> src = source.getTestResources();
2406 if ( !src.isEmpty() )
2407 {
2408 List<Resource> tgt = target.getTestResources();
2409 Map<Object, Resource> merged = new LinkedHashMap<Object, Resource>( ( src.size() + tgt.size() ) * 2 );
2410
2411 for ( Resource element : tgt )
2412 {
2413 Object key = getResourceKey( element );
2414 merged.put( key, element );
2415 }
2416
2417 for ( Resource element : src )
2418 {
2419 Object key = getResourceKey( element );
2420 if ( sourceDominant || !merged.containsKey( key ) )
2421 {
2422 merged.put( key, element );
2423 }
2424 }
2425
2426 target.setTestResources( new ArrayList<Resource>( merged.values() ) );
2427 }
2428 }
2429
2430 protected void mergePluginConfiguration( PluginConfiguration target, PluginConfiguration source,
2431 boolean sourceDominant, Map<Object, Object> context )
2432 {
2433 mergePluginContainer( target, source, sourceDominant, context );
2434 mergePluginConfiguration_PluginManagement( target, source, sourceDominant, context );
2435 }
2436
2437 protected void mergePluginConfiguration_PluginManagement( PluginConfiguration target, PluginConfiguration source,
2438 boolean sourceDominant, Map<Object, Object> context )
2439 {
2440 PluginManagement src = source.getPluginManagement();
2441 if ( source.getPluginManagement() != null )
2442 {
2443 PluginManagement tgt = target.getPluginManagement();
2444 if ( tgt == null )
2445 {
2446 tgt = new PluginManagement();
2447 target.setPluginManagement( tgt );
2448 }
2449 mergePluginManagement( tgt, src, sourceDominant, context );
2450 }
2451 }
2452
2453 protected void mergePluginContainer( PluginContainer target, PluginContainer source, boolean sourceDominant,
2454 Map<Object, Object> context )
2455 {
2456 mergePluginContainer_Plugins( target, source, sourceDominant, context );
2457 }
2458
2459 protected void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source,
2460 boolean sourceDominant, Map<Object, Object> context )
2461 {
2462 List<Plugin> src = source.getPlugins();
2463 if ( !src.isEmpty() )
2464 {
2465 List<Plugin> tgt = target.getPlugins();
2466 Map<Object, Plugin> merged = new LinkedHashMap<Object, Plugin>( ( src.size() + tgt.size() ) * 2 );
2467
2468 for ( Plugin element : tgt )
2469 {
2470 Object key = getPluginKey( element );
2471 merged.put( key, element );
2472 }
2473
2474 for ( Plugin element : src )
2475 {
2476 Object key = getPluginKey( element );
2477 if ( sourceDominant || !merged.containsKey( key ) )
2478 {
2479 merged.put( key, element );
2480 }
2481 }
2482
2483 target.setPlugins( new ArrayList<Plugin>( merged.values() ) );
2484 }
2485 }
2486
2487 protected void mergePluginManagement( PluginManagement target, PluginManagement source, boolean sourceDominant,
2488 Map<Object, Object> context )
2489 {
2490 mergePluginContainer( target, source, sourceDominant, context );
2491 }
2492
2493 protected void mergePlugin( Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2494 {
2495 mergeConfigurationContainer( target, source, sourceDominant, context );
2496 mergePlugin_GroupId( target, source, sourceDominant, context );
2497 mergePlugin_ArtifactId( target, source, sourceDominant, context );
2498 mergePlugin_Version( target, source, sourceDominant, context );
2499 mergePlugin_Extensions( target, source, sourceDominant, context );
2500 mergePlugin_Dependencies( target, source, sourceDominant, context );
2501 mergePlugin_Executions( target, source, sourceDominant, context );
2502 }
2503
2504 protected void mergePlugin_GroupId( Plugin target, Plugin source, boolean sourceDominant,
2505 Map<Object, Object> context )
2506 {
2507 String src = source.getGroupId();
2508 if ( src != null )
2509 {
2510 if ( sourceDominant || target.getGroupId() == null )
2511 {
2512 target.setGroupId( src );
2513 target.setLocation( "groupId", source.getLocation( "groupId" ) );
2514 }
2515 }
2516 }
2517
2518 protected void mergePlugin_ArtifactId( Plugin target, Plugin source, boolean sourceDominant,
2519 Map<Object, Object> context )
2520 {
2521 String src = source.getArtifactId();
2522 if ( src != null )
2523 {
2524 if ( sourceDominant || target.getArtifactId() == null )
2525 {
2526 target.setArtifactId( src );
2527 target.setLocation( "artifactId", source.getLocation( "artifactId" ) );
2528 }
2529 }
2530 }
2531
2532 protected void mergePlugin_Version( Plugin target, Plugin source, boolean sourceDominant,
2533 Map<Object, Object> context )
2534 {
2535 String src = source.getVersion();
2536 if ( src != null )
2537 {
2538 if ( sourceDominant || target.getVersion() == null )
2539 {
2540 target.setVersion( src );
2541 target.setLocation( "version", source.getLocation( "version" ) );
2542 }
2543 }
2544 }
2545
2546 protected void mergePlugin_Extensions( Plugin target, Plugin source, boolean sourceDominant,
2547 Map<Object, Object> context )
2548 {
2549 String src = source.getExtensions();
2550 if ( src != null )
2551 {
2552 if ( sourceDominant || target.getExtensions() == null )
2553 {
2554 target.setExtensions( src );
2555 target.setLocation( "extensions", source.getLocation( "extensions" ) );
2556 }
2557 }
2558 }
2559
2560 protected void mergePlugin_Dependencies( Plugin target, Plugin source, boolean sourceDominant,
2561 Map<Object, Object> context )
2562 {
2563 List<Dependency> src = source.getDependencies();
2564 if ( !src.isEmpty() )
2565 {
2566 List<Dependency> tgt = target.getDependencies();
2567 Map<Object, Dependency> merged = new LinkedHashMap<Object, Dependency>( ( src.size() + tgt.size() ) * 2 );
2568
2569 for ( Dependency element : tgt )
2570 {
2571 Object key = getDependencyKey( element );
2572 merged.put( key, element );
2573 }
2574
2575 for ( Dependency element : src )
2576 {
2577 Object key = getDependencyKey( element );
2578 if ( sourceDominant || !merged.containsKey( key ) )
2579 {
2580 merged.put( key, element );
2581 }
2582 }
2583
2584 target.setDependencies( new ArrayList<Dependency>( merged.values() ) );
2585 }
2586 }
2587
2588 protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant,
2589 Map<Object, Object> context )
2590 {
2591 List<PluginExecution> src = source.getExecutions();
2592 if ( !src.isEmpty() )
2593 {
2594 List<PluginExecution> tgt = target.getExecutions();
2595
2596 Map<Object, PluginExecution> merged =
2597 new LinkedHashMap<Object, PluginExecution>( ( src.size() + tgt.size() ) * 2 );
2598
2599 for ( PluginExecution element : tgt )
2600 {
2601 Object key = getPluginExecutionKey( element );
2602 merged.put( key, element );
2603 }
2604
2605 for ( PluginExecution element : src )
2606 {
2607 Object key = getPluginExecutionKey( element );
2608 if ( sourceDominant || !merged.containsKey( key ) )
2609 {
2610 merged.put( key, element );
2611 }
2612 }
2613
2614 target.setExecutions( new ArrayList<PluginExecution>( merged.values() ) );
2615 }
2616 }
2617
2618 protected void mergeConfigurationContainer( ConfigurationContainer target, ConfigurationContainer source,
2619 boolean sourceDominant, Map<Object, Object> context )
2620 {
2621 mergeConfigurationContainer_Inherited( target, source, sourceDominant, context );
2622 mergeConfigurationContainer_Configuration( target, source, sourceDominant, context );
2623 }
2624
2625 protected void mergeConfigurationContainer_Inherited( ConfigurationContainer target, ConfigurationContainer source,
2626 boolean sourceDominant, Map<Object, Object> context )
2627 {
2628 String src = source.getInherited();
2629 if ( src != null )
2630 {
2631 if ( sourceDominant || target.getInherited() == null )
2632 {
2633 target.setInherited( src );
2634 target.setLocation( "inherited", source.getLocation( "inherited" ) );
2635 }
2636 }
2637 }
2638
2639 protected void mergeConfigurationContainer_Configuration( ConfigurationContainer target,
2640 ConfigurationContainer source, boolean sourceDominant,
2641 Map<Object, Object> context )
2642 {
2643 Xpp3Dom src = (Xpp3Dom) source.getConfiguration();
2644 if ( src != null )
2645 {
2646 Xpp3Dom tgt = (Xpp3Dom) target.getConfiguration();
2647 if ( sourceDominant || tgt == null )
2648 {
2649 tgt = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( src ), tgt );
2650 }
2651 else
2652 {
2653 tgt = Xpp3Dom.mergeXpp3Dom( tgt, src );
2654 }
2655 target.setConfiguration( tgt );
2656 }
2657 }
2658
2659 protected void mergePluginExecution( PluginExecution target, PluginExecution source, boolean sourceDominant,
2660 Map<Object, Object> context )
2661 {
2662 mergeConfigurationContainer( target, source, sourceDominant, context );
2663 mergePluginExecution_Id( target, source, sourceDominant, context );
2664 mergePluginExecution_Phase( target, source, sourceDominant, context );
2665 mergePluginExecution_Goals( target, source, sourceDominant, context );
2666 }
2667
2668 protected void mergePluginExecution_Id( PluginExecution target, PluginExecution source, boolean sourceDominant,
2669 Map<Object, Object> context )
2670 {
2671 String src = source.getId();
2672 if ( src != null )
2673 {
2674 if ( sourceDominant || target.getId() == null )
2675 {
2676 target.setId( src );
2677 target.setLocation( "id", source.getLocation( "id" ) );
2678 }
2679 }
2680 }
2681
2682 protected void mergePluginExecution_Phase( PluginExecution target, PluginExecution source, boolean sourceDominant,
2683 Map<Object, Object> context )
2684 {
2685 String src = source.getPhase();
2686 if ( src != null )
2687 {
2688 if ( sourceDominant || target.getPhase() == null )
2689 {
2690 target.setPhase( src );
2691 target.setLocation( "phase", source.getLocation( "phase" ) );
2692 }
2693 }
2694 }
2695
2696 protected void mergePluginExecution_Goals( PluginExecution target, PluginExecution source, boolean sourceDominant,
2697 Map<Object, Object> context )
2698 {
2699 List<String> src = source.getGoals();
2700 if ( !src.isEmpty() )
2701 {
2702 List<String> tgt = target.getGoals();
2703 List<String> merged = new ArrayList<String>( tgt.size() + src.size() );
2704 merged.addAll( tgt );
2705 merged.addAll( src );
2706 target.setGoals( merged );
2707 }
2708 }
2709
2710 protected void mergeResource( Resource target, Resource source, boolean sourceDominant,
2711 Map<Object, Object> context )
2712 {
2713 mergeFileSet( target, source, sourceDominant, context );
2714 mergeResource_TargetPath( target, source, sourceDominant, context );
2715 mergeResource_Filtering( target, source, sourceDominant, context );
2716 mergeResource_MergeId( target, source, sourceDominant, context );
2717 }
2718
2719 protected void mergeResource_TargetPath( Resource target, Resource source, boolean sourceDominant,
2720 Map<Object, Object> context )
2721 {
2722 String src = source.getTargetPath();
2723 if ( src != null )
2724 {
2725 if ( sourceDominant || target.getTargetPath() == null )
2726 {
2727 target.setTargetPath( src );
2728 target.setLocation( "targetPath", source.getLocation( "targetPath" ) );
2729 }
2730 }
2731 }
2732
2733 protected void mergeResource_Filtering( Resource target, Resource source, boolean sourceDominant,
2734 Map<Object, Object> context )
2735 {
2736 String src = source.getFiltering();
2737 if ( src != null )
2738 {
2739 if ( sourceDominant || target.getFiltering() == null )
2740 {
2741 target.setFiltering( src );
2742 target.setLocation( "filtering", source.getLocation( "filtering" ) );
2743 }
2744 }
2745 }
2746
2747 protected void mergeResource_MergeId( Resource target, Resource source, boolean sourceDominant,
2748 Map<Object, Object> context )
2749 {
2750 String src = source.getMergeId();
2751 if ( src != null )
2752 {
2753 if ( sourceDominant || target.getMergeId() == null )
2754 {
2755 target.setMergeId( src );
2756 }
2757 }
2758 }
2759
2760 protected void mergeFileSet( FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context )
2761 {
2762 mergePatternSet( target, source, sourceDominant, context );
2763 mergeFileSet_Directory( target, source, sourceDominant, context );
2764 }
2765
2766 protected void mergeFileSet_Directory( FileSet target, FileSet source, boolean sourceDominant,
2767 Map<Object, Object> context )
2768 {
2769 String src = source.getDirectory();
2770 if ( src != null )
2771 {
2772 if ( sourceDominant || target.getDirectory() == null )
2773 {
2774 target.setDirectory( src );
2775 target.setLocation( "directory", source.getLocation( "directory" ) );
2776 }
2777 }
2778 }
2779
2780 protected void mergePatternSet( PatternSet target, PatternSet source, boolean sourceDominant,
2781 Map<Object, Object> context )
2782 {
2783 mergePatternSet_Includes( target, source, sourceDominant, context );
2784 mergePatternSet_Excludes( target, source, sourceDominant, context );
2785 }
2786
2787 protected void mergePatternSet_Includes( PatternSet target, PatternSet source, boolean sourceDominant,
2788 Map<Object, Object> context )
2789 {
2790 List<String> src = source.getIncludes();
2791 if ( !src.isEmpty() )
2792 {
2793 List<String> tgt = target.getIncludes();
2794 List<String> merged = new ArrayList<String>( tgt.size() + src.size() );
2795 merged.addAll( tgt );
2796 merged.addAll( src );
2797 target.setIncludes( merged );
2798 }
2799 }
2800
2801 protected void mergePatternSet_Excludes( PatternSet target, PatternSet source, boolean sourceDominant,
2802 Map<Object, Object> context )
2803 {
2804 List<String> src = source.getExcludes();
2805 if ( !src.isEmpty() )
2806 {
2807 List<String> tgt = target.getExcludes();
2808 List<String> merged = new ArrayList<String>( tgt.size() + src.size() );
2809 merged.addAll( tgt );
2810 merged.addAll( src );
2811 target.setExcludes( merged );
2812 }
2813 }
2814
2815 protected void mergeProfile( Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2816 {
2817 mergeModelBase( target, source, sourceDominant, context );
2818
2819 }
2820
2821 protected void mergeActivation( Activation target, Activation source, boolean sourceDominant,
2822 Map<Object, Object> context )
2823 {
2824
2825 }
2826
2827 protected Object getDependencyKey( Dependency dependency )
2828 {
2829 return dependency;
2830 }
2831
2832 protected Object getPluginKey( Plugin object )
2833 {
2834 return object;
2835 }
2836
2837 protected Object getPluginExecutionKey( PluginExecution object )
2838 {
2839 return object;
2840 }
2841
2842 protected Object getReportPluginKey( ReportPlugin object )
2843 {
2844 return object;
2845 }
2846
2847 protected Object getReportSetKey( ReportSet object )
2848 {
2849 return object;
2850 }
2851
2852 protected Object getLicenseKey( License object )
2853 {
2854 return object;
2855 }
2856
2857 protected Object getMailingListKey( MailingList object )
2858 {
2859 return object;
2860 }
2861
2862 protected Object getDeveloperKey( Developer object )
2863 {
2864 return object;
2865 }
2866
2867 protected Object getContributorKey( Contributor object )
2868 {
2869 return object;
2870 }
2871
2872 protected Object getProfileKey( Profile object )
2873 {
2874 return object;
2875 }
2876
2877 protected Object getRepositoryKey( Repository object )
2878 {
2879 return getRepositoryBaseKey( object );
2880 }
2881
2882 protected Object getRepositoryBaseKey( RepositoryBase object )
2883 {
2884 return object;
2885 }
2886
2887 protected Object getNotifierKey( Notifier object )
2888 {
2889 return object;
2890 }
2891
2892 protected Object getResourceKey( Resource object )
2893 {
2894 return object;
2895 }
2896
2897 protected Object getExtensionKey( Extension object )
2898 {
2899 return object;
2900 }
2901
2902 protected Object getExclusionKey( Exclusion object )
2903 {
2904 return object;
2905 }
2906
2907 }