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