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