1
2
3
4
5 package org.apache.maven.model.v4;
6
7 import java.io.ObjectStreamException;
8 import java.util.AbstractList;
9 import java.util.ArrayList;
10 import java.util.Collection;
11 import java.util.HashMap;
12 import java.util.Iterator;
13 import java.util.LinkedHashMap;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.Objects;
17 import java.util.function.BinaryOperator;
18 import java.util.function.Function;
19 import java.util.stream.Collectors;
20
21 import org.apache.maven.api.annotations.Generated;
22 import org.apache.maven.api.xml.XmlNode;
23 import org.apache.maven.api.model.Model;
24 import org.apache.maven.api.model.ModelBase;
25 import org.apache.maven.api.model.PluginContainer;
26 import org.apache.maven.api.model.PluginConfiguration;
27 import org.apache.maven.api.model.BuildBase;
28 import org.apache.maven.api.model.Build;
29 import org.apache.maven.api.model.CiManagement;
30 import org.apache.maven.api.model.Notifier;
31 import org.apache.maven.api.model.Contributor;
32 import org.apache.maven.api.model.Dependency;
33 import org.apache.maven.api.model.Developer;
34 import org.apache.maven.api.model.Exclusion;
35 import org.apache.maven.api.model.IssueManagement;
36 import org.apache.maven.api.model.DistributionManagement;
37 import org.apache.maven.api.model.License;
38 import org.apache.maven.api.model.MailingList;
39 import org.apache.maven.api.model.Organization;
40 import org.apache.maven.api.model.PatternSet;
41 import org.apache.maven.api.model.Parent;
42 import org.apache.maven.api.model.Scm;
43 import org.apache.maven.api.model.FileSet;
44 import org.apache.maven.api.model.Resource;
45 import org.apache.maven.api.model.RepositoryBase;
46 import org.apache.maven.api.model.Repository;
47 import org.apache.maven.api.model.DeploymentRepository;
48 import org.apache.maven.api.model.RepositoryPolicy;
49 import org.apache.maven.api.model.Site;
50 import org.apache.maven.api.model.ConfigurationContainer;
51 import org.apache.maven.api.model.Plugin;
52 import org.apache.maven.api.model.PluginExecution;
53 import org.apache.maven.api.model.DependencyManagement;
54 import org.apache.maven.api.model.PluginManagement;
55 import org.apache.maven.api.model.Reporting;
56 import org.apache.maven.api.model.Profile;
57 import org.apache.maven.api.model.Activation;
58 import org.apache.maven.api.model.ActivationProperty;
59 import org.apache.maven.api.model.ActivationOS;
60 import org.apache.maven.api.model.ActivationFile;
61 import org.apache.maven.api.model.ReportPlugin;
62 import org.apache.maven.api.model.ReportSet;
63 import org.apache.maven.api.model.Prerequisites;
64 import org.apache.maven.api.model.Relocation;
65 import org.apache.maven.api.model.Extension;
66 import org.apache.maven.api.model.InputLocation;
67 import org.apache.maven.api.model.InputSource;
68
69 @Generated
70 public class MavenMerger
71 {
72
73 private final boolean deepMerge;
74
75 public MavenMerger() {
76 this(true);
77 }
78
79 public MavenMerger(boolean deepMerge) {
80 this.deepMerge = deepMerge;
81 }
82
83
84
85
86
87
88
89
90
91
92
93
94
95 public Model merge( Model target, Model source, boolean sourceDominant, Map<?, ?> hints )
96 {
97 Objects.requireNonNull( target, "target cannot be null" );
98 if ( source == null )
99 {
100 return target;
101 }
102 Map<Object, Object> context = new HashMap<>();
103 if ( hints != null )
104 {
105 context.putAll( hints );
106 }
107 return mergeModel( target, source, sourceDominant, context );
108 }
109
110 protected Model mergeModel( Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
111 {
112 Model.Builder builder = Model.newBuilder( target );
113 mergeModel( builder, target, source, sourceDominant, context );
114 return builder.build();
115 }
116
117 protected void mergeModel( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
118 {
119 mergeModelBase( builder, target ,source, sourceDominant, context );
120 mergeModel_PomFile( builder, target, source, sourceDominant, context );
121 mergeModel_ModelVersion( builder, target, source, sourceDominant, context );
122 mergeModel_Parent( builder, target, source, sourceDominant, context );
123 mergeModel_GroupId( builder, target, source, sourceDominant, context );
124 mergeModel_ArtifactId( builder, target, source, sourceDominant, context );
125 mergeModel_Version( builder, target, source, sourceDominant, context );
126 mergeModel_Packaging( builder, target, source, sourceDominant, context );
127 mergeModel_Name( builder, target, source, sourceDominant, context );
128 mergeModel_Description( builder, target, source, sourceDominant, context );
129 mergeModel_Url( builder, target, source, sourceDominant, context );
130 mergeModel_ChildProjectUrlInheritAppendPath( builder, target, source, sourceDominant, context );
131 mergeModel_InceptionYear( builder, target, source, sourceDominant, context );
132 mergeModel_Organization( builder, target, source, sourceDominant, context );
133 mergeModel_Licenses( builder, target, source, sourceDominant, context );
134 mergeModel_Developers( builder, target, source, sourceDominant, context );
135 mergeModel_Contributors( builder, target, source, sourceDominant, context );
136 mergeModel_MailingLists( builder, target, source, sourceDominant, context );
137 mergeModel_Prerequisites( builder, target, source, sourceDominant, context );
138 mergeModel_Scm( builder, target, source, sourceDominant, context );
139 mergeModel_IssueManagement( builder, target, source, sourceDominant, context );
140 mergeModel_CiManagement( builder, target, source, sourceDominant, context );
141 mergeModel_Build( builder, target, source, sourceDominant, context );
142 mergeModel_Profiles( builder, target, source, sourceDominant, context );
143 }
144
145 protected void mergeModel_Modules( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
146 {
147 builder.modules( merge( target.getModules(), source.getModules(), sourceDominant, e -> e ) );
148 }
149 protected void mergeModel_DistributionManagement( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
150 {
151 DistributionManagement src = source.getDistributionManagement();
152 if ( src != null )
153 {
154 DistributionManagement tgt = target.getDistributionManagement();
155 if ( tgt == null )
156 {
157 tgt = DistributionManagement.newInstance( false );
158 }
159 DistributionManagement merged = mergeDistributionManagement( tgt, src, sourceDominant, context );
160 if ( merged == src )
161 {
162 builder.distributionManagement( merged );
163 builder.location( "distributionManagement", source.getLocation( "distributionManagement" ) );
164 }
165 else if ( merged != tgt )
166 {
167 builder.distributionManagement( merged );
168 builder.location( "distributionManagement", InputLocation.merge( target.getLocation( "distributionManagement" ), source.getLocation( "distributionManagement" ), sourceDominant ) );
169 }
170 }
171 }
172 protected void mergeModel_Properties( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
173 {
174 Map<String, String> src = source.getProperties();
175 if ( !src.isEmpty() )
176 {
177 Map<String, String> tgt = target.getProperties();
178 if ( tgt.isEmpty() )
179 {
180 builder.properties( src );
181 builder.location( "properties", source.getLocation( "properties" ) );
182 }
183 else
184 {
185 Map<String, String> merged = new HashMap<>();
186 merged.putAll( sourceDominant ? target.getProperties() : source.getProperties() );
187 merged.putAll( sourceDominant ? source.getProperties() : target.getProperties() );
188 builder.properties( merged );
189 builder.location( "properties", InputLocation.merge( target.getLocation( "properties" ), source.getLocation( "properties" ), sourceDominant ) );
190 }
191 }
192 }
193 protected void mergeModel_DependencyManagement( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
194 {
195 DependencyManagement src = source.getDependencyManagement();
196 if ( src != null )
197 {
198 DependencyManagement tgt = target.getDependencyManagement();
199 if ( tgt == null )
200 {
201 tgt = DependencyManagement.newInstance( false );
202 }
203 DependencyManagement merged = mergeDependencyManagement( tgt, src, sourceDominant, context );
204 if ( merged == src )
205 {
206 builder.dependencyManagement( merged );
207 builder.location( "dependencyManagement", source.getLocation( "dependencyManagement" ) );
208 }
209 else if ( merged != tgt )
210 {
211 builder.dependencyManagement( merged );
212 builder.location( "dependencyManagement", InputLocation.merge( target.getLocation( "dependencyManagement" ), source.getLocation( "dependencyManagement" ), sourceDominant ) );
213 }
214 }
215 }
216 protected void mergeModel_Dependencies( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
217 {
218 if (deepMerge) {
219 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), getDependencyKey(),
220 ( t, s ) -> mergeDependency( t, s, sourceDominant, context ) ) );
221 } else {
222 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey() ) );
223 }
224 }
225 protected void mergeModel_Repositories( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
226 {
227 if (deepMerge) {
228 builder.repositories( merge( target.getRepositories(), source.getRepositories(), getRepositoryKey(),
229 ( t, s ) -> mergeRepository( t, s, sourceDominant, context ) ) );
230 } else {
231 builder.repositories( merge( target.getRepositories(), source.getRepositories(), sourceDominant, getRepositoryKey() ) );
232 }
233 }
234 protected void mergeModel_PluginRepositories( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
235 {
236 if (deepMerge) {
237 builder.pluginRepositories( merge( target.getPluginRepositories(), source.getPluginRepositories(), getRepositoryKey(),
238 ( t, s ) -> mergeRepository( t, s, sourceDominant, context ) ) );
239 } else {
240 builder.pluginRepositories( merge( target.getPluginRepositories(), source.getPluginRepositories(), sourceDominant, getRepositoryKey() ) );
241 }
242 }
243 protected void mergeModel_Reporting( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
244 {
245 Reporting src = source.getReporting();
246 if ( src != null )
247 {
248 Reporting tgt = target.getReporting();
249 if ( tgt == null )
250 {
251 tgt = Reporting.newInstance( false );
252 }
253 Reporting merged = mergeReporting( tgt, src, sourceDominant, context );
254 if ( merged == src )
255 {
256 builder.reporting( merged );
257 builder.location( "reporting", source.getLocation( "reporting" ) );
258 }
259 else if ( merged != tgt )
260 {
261 builder.reporting( merged );
262 builder.location( "reporting", InputLocation.merge( target.getLocation( "reporting" ), source.getLocation( "reporting" ), sourceDominant ) );
263 }
264 }
265 }
266 protected void mergeModel_PomFile( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
267 {
268 if ( sourceDominant )
269 {
270 builder.pomFile( source.getPomFile() );
271 }
272 }
273 protected void mergeModel_ModelVersion( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
274 {
275 String src = source.getModelVersion();
276 String tgt = target.getModelVersion();
277 if ( src != null && ( sourceDominant || tgt == null ) )
278 {
279 builder.modelVersion( src );
280 builder.location( "modelVersion", source.getLocation( "modelVersion" ) );
281 }
282 }
283 protected void mergeModel_Parent( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
284 {
285 Parent src = source.getParent();
286 if ( src != null )
287 {
288 Parent tgt = target.getParent();
289 if ( tgt == null )
290 {
291 tgt = Parent.newInstance( false );
292 }
293 Parent merged = mergeParent( tgt, src, sourceDominant, context );
294 if ( merged == src )
295 {
296 builder.parent( merged );
297 builder.location( "parent", source.getLocation( "parent" ) );
298 }
299 else if ( merged != tgt )
300 {
301 builder.parent( merged );
302 builder.location( "parent", InputLocation.merge( target.getLocation( "parent" ), source.getLocation( "parent" ), sourceDominant ) );
303 }
304 }
305 }
306 protected void mergeModel_GroupId( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
307 {
308 String src = source.getGroupId();
309 String tgt = target.getGroupId();
310 if ( src != null && ( sourceDominant || tgt == null ) )
311 {
312 builder.groupId( src );
313 builder.location( "groupId", source.getLocation( "groupId" ) );
314 }
315 }
316 protected void mergeModel_ArtifactId( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
317 {
318 String src = source.getArtifactId();
319 String tgt = target.getArtifactId();
320 if ( src != null && ( sourceDominant || tgt == null ) )
321 {
322 builder.artifactId( src );
323 builder.location( "artifactId", source.getLocation( "artifactId" ) );
324 }
325 }
326 protected void mergeModel_Version( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
327 {
328 String src = source.getVersion();
329 String tgt = target.getVersion();
330 if ( src != null && ( sourceDominant || tgt == null ) )
331 {
332 builder.version( src );
333 builder.location( "version", source.getLocation( "version" ) );
334 }
335 }
336 protected void mergeModel_Packaging( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
337 {
338 String src = source.getPackaging();
339 String tgt = target.getPackaging();
340 if ( src != null && ( sourceDominant || tgt == null ) )
341 {
342 builder.packaging( src );
343 builder.location( "packaging", source.getLocation( "packaging" ) );
344 }
345 }
346 protected void mergeModel_Name( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
347 {
348 String src = source.getName();
349 String tgt = target.getName();
350 if ( src != null && ( sourceDominant || tgt == null ) )
351 {
352 builder.name( src );
353 builder.location( "name", source.getLocation( "name" ) );
354 }
355 }
356 protected void mergeModel_Description( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
357 {
358 String src = source.getDescription();
359 String tgt = target.getDescription();
360 if ( src != null && ( sourceDominant || tgt == null ) )
361 {
362 builder.description( src );
363 builder.location( "description", source.getLocation( "description" ) );
364 }
365 }
366 protected void mergeModel_Url( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
367 {
368 String src = source.getUrl();
369 String tgt = target.getUrl();
370 if ( src != null && ( sourceDominant || tgt == null ) )
371 {
372 builder.url( src );
373 builder.location( "url", source.getLocation( "url" ) );
374 }
375 }
376 protected void mergeModel_ChildProjectUrlInheritAppendPath( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
377 {
378 String src = source.getChildProjectUrlInheritAppendPath();
379 String tgt = target.getChildProjectUrlInheritAppendPath();
380 if ( src != null && ( sourceDominant || tgt == null ) )
381 {
382 builder.childProjectUrlInheritAppendPath( src );
383 builder.location( "childProjectUrlInheritAppendPath", source.getLocation( "childProjectUrlInheritAppendPath" ) );
384 }
385 }
386 protected void mergeModel_InceptionYear( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
387 {
388 String src = source.getInceptionYear();
389 String tgt = target.getInceptionYear();
390 if ( src != null && ( sourceDominant || tgt == null ) )
391 {
392 builder.inceptionYear( src );
393 builder.location( "inceptionYear", source.getLocation( "inceptionYear" ) );
394 }
395 }
396 protected void mergeModel_Organization( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
397 {
398 Organization src = source.getOrganization();
399 if ( src != null )
400 {
401 Organization tgt = target.getOrganization();
402 if ( tgt == null )
403 {
404 tgt = Organization.newInstance( false );
405 }
406 Organization merged = mergeOrganization( tgt, src, sourceDominant, context );
407 if ( merged == src )
408 {
409 builder.organization( merged );
410 builder.location( "organization", source.getLocation( "organization" ) );
411 }
412 else if ( merged != tgt )
413 {
414 builder.organization( merged );
415 builder.location( "organization", InputLocation.merge( target.getLocation( "organization" ), source.getLocation( "organization" ), sourceDominant ) );
416 }
417 }
418 }
419 protected void mergeModel_Licenses( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
420 {
421 if (deepMerge) {
422 builder.licenses( merge( target.getLicenses(), source.getLicenses(), getLicenseKey(),
423 ( t, s ) -> mergeLicense( t, s, sourceDominant, context ) ) );
424 } else {
425 builder.licenses( merge( target.getLicenses(), source.getLicenses(), sourceDominant, getLicenseKey() ) );
426 }
427 }
428 protected void mergeModel_Developers( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
429 {
430 if (deepMerge) {
431 builder.developers( merge( target.getDevelopers(), source.getDevelopers(), getDeveloperKey(),
432 ( t, s ) -> mergeDeveloper( t, s, sourceDominant, context ) ) );
433 } else {
434 builder.developers( merge( target.getDevelopers(), source.getDevelopers(), sourceDominant, getDeveloperKey() ) );
435 }
436 }
437 protected void mergeModel_Contributors( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
438 {
439 if (deepMerge) {
440 builder.contributors( merge( target.getContributors(), source.getContributors(), getContributorKey(),
441 ( t, s ) -> mergeContributor( t, s, sourceDominant, context ) ) );
442 } else {
443 builder.contributors( merge( target.getContributors(), source.getContributors(), sourceDominant, getContributorKey() ) );
444 }
445 }
446 protected void mergeModel_MailingLists( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
447 {
448 if (deepMerge) {
449 builder.mailingLists( merge( target.getMailingLists(), source.getMailingLists(), getMailingListKey(),
450 ( t, s ) -> mergeMailingList( t, s, sourceDominant, context ) ) );
451 } else {
452 builder.mailingLists( merge( target.getMailingLists(), source.getMailingLists(), sourceDominant, getMailingListKey() ) );
453 }
454 }
455 protected void mergeModel_Prerequisites( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
456 {
457 Prerequisites src = source.getPrerequisites();
458 if ( src != null )
459 {
460 Prerequisites tgt = target.getPrerequisites();
461 if ( tgt == null )
462 {
463 tgt = Prerequisites.newInstance( false );
464 }
465 Prerequisites merged = mergePrerequisites( tgt, src, sourceDominant, context );
466 if ( merged == src )
467 {
468 builder.prerequisites( merged );
469 builder.location( "prerequisites", source.getLocation( "prerequisites" ) );
470 }
471 else if ( merged != tgt )
472 {
473 builder.prerequisites( merged );
474 builder.location( "prerequisites", InputLocation.merge( target.getLocation( "prerequisites" ), source.getLocation( "prerequisites" ), sourceDominant ) );
475 }
476 }
477 }
478 protected void mergeModel_Scm( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
479 {
480 Scm src = source.getScm();
481 if ( src != null )
482 {
483 Scm tgt = target.getScm();
484 if ( tgt == null )
485 {
486 tgt = Scm.newInstance( false );
487 }
488 Scm merged = mergeScm( tgt, src, sourceDominant, context );
489 if ( merged == src )
490 {
491 builder.scm( merged );
492 builder.location( "scm", source.getLocation( "scm" ) );
493 }
494 else if ( merged != tgt )
495 {
496 builder.scm( merged );
497 builder.location( "scm", InputLocation.merge( target.getLocation( "scm" ), source.getLocation( "scm" ), sourceDominant ) );
498 }
499 }
500 }
501 protected void mergeModel_IssueManagement( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
502 {
503 IssueManagement src = source.getIssueManagement();
504 if ( src != null )
505 {
506 IssueManagement tgt = target.getIssueManagement();
507 if ( tgt == null )
508 {
509 tgt = IssueManagement.newInstance( false );
510 }
511 IssueManagement merged = mergeIssueManagement( tgt, src, sourceDominant, context );
512 if ( merged == src )
513 {
514 builder.issueManagement( merged );
515 builder.location( "issueManagement", source.getLocation( "issueManagement" ) );
516 }
517 else if ( merged != tgt )
518 {
519 builder.issueManagement( merged );
520 builder.location( "issueManagement", InputLocation.merge( target.getLocation( "issueManagement" ), source.getLocation( "issueManagement" ), sourceDominant ) );
521 }
522 }
523 }
524 protected void mergeModel_CiManagement( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
525 {
526 CiManagement src = source.getCiManagement();
527 if ( src != null )
528 {
529 CiManagement tgt = target.getCiManagement();
530 if ( tgt == null )
531 {
532 tgt = CiManagement.newInstance( false );
533 }
534 CiManagement merged = mergeCiManagement( tgt, src, sourceDominant, context );
535 if ( merged == src )
536 {
537 builder.ciManagement( merged );
538 builder.location( "ciManagement", source.getLocation( "ciManagement" ) );
539 }
540 else if ( merged != tgt )
541 {
542 builder.ciManagement( merged );
543 builder.location( "ciManagement", InputLocation.merge( target.getLocation( "ciManagement" ), source.getLocation( "ciManagement" ), sourceDominant ) );
544 }
545 }
546 }
547 protected void mergeModel_Build( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
548 {
549 Build src = source.getBuild();
550 if ( src != null )
551 {
552 Build tgt = target.getBuild();
553 if ( tgt == null )
554 {
555 tgt = Build.newInstance( false );
556 }
557 Build merged = mergeBuild( tgt, src, sourceDominant, context );
558 if ( merged == src )
559 {
560 builder.build( merged );
561 builder.location( "build", source.getLocation( "build" ) );
562 }
563 else if ( merged != tgt )
564 {
565 builder.build( merged );
566 builder.location( "build", InputLocation.merge( target.getLocation( "build" ), source.getLocation( "build" ), sourceDominant ) );
567 }
568 }
569 }
570 protected void mergeModel_Profiles( Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context )
571 {
572 if (deepMerge) {
573 builder.profiles( merge( target.getProfiles(), source.getProfiles(), getProfileKey(),
574 ( t, s ) -> mergeProfile( t, s, sourceDominant, context ) ) );
575 } else {
576 builder.profiles( merge( target.getProfiles(), source.getProfiles(), sourceDominant, getProfileKey() ) );
577 }
578 }
579
580 protected ModelBase mergeModelBase( ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
581 {
582 ModelBase.Builder builder = ModelBase.newBuilder( target );
583 mergeModelBase( builder, target, source, sourceDominant, context );
584 return builder.build();
585 }
586
587 protected void mergeModelBase( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
588 {
589 mergeModelBase_Modules( builder, target, source, sourceDominant, context );
590 mergeModelBase_DistributionManagement( builder, target, source, sourceDominant, context );
591 mergeModelBase_Properties( builder, target, source, sourceDominant, context );
592 mergeModelBase_DependencyManagement( builder, target, source, sourceDominant, context );
593 mergeModelBase_Dependencies( builder, target, source, sourceDominant, context );
594 mergeModelBase_Repositories( builder, target, source, sourceDominant, context );
595 mergeModelBase_PluginRepositories( builder, target, source, sourceDominant, context );
596 mergeModelBase_Reporting( builder, target, source, sourceDominant, context );
597 }
598
599 protected void mergeModelBase_Modules( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
600 {
601 builder.modules( merge( target.getModules(), source.getModules(), sourceDominant, e -> e ) );
602 }
603 protected void mergeModelBase_DistributionManagement( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
604 {
605 DistributionManagement src = source.getDistributionManagement();
606 if ( src != null )
607 {
608 DistributionManagement tgt = target.getDistributionManagement();
609 if ( tgt == null )
610 {
611 tgt = DistributionManagement.newInstance( false );
612 }
613 DistributionManagement merged = mergeDistributionManagement( tgt, src, sourceDominant, context );
614 if ( merged == src )
615 {
616 builder.distributionManagement( merged );
617 builder.location( "distributionManagement", source.getLocation( "distributionManagement" ) );
618 }
619 else if ( merged != tgt )
620 {
621 builder.distributionManagement( merged );
622 builder.location( "distributionManagement", InputLocation.merge( target.getLocation( "distributionManagement" ), source.getLocation( "distributionManagement" ), sourceDominant ) );
623 }
624 }
625 }
626 protected void mergeModelBase_Properties( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
627 {
628 Map<String, String> src = source.getProperties();
629 if ( !src.isEmpty() )
630 {
631 Map<String, String> tgt = target.getProperties();
632 if ( tgt.isEmpty() )
633 {
634 builder.properties( src );
635 builder.location( "properties", source.getLocation( "properties" ) );
636 }
637 else
638 {
639 Map<String, String> merged = new HashMap<>();
640 merged.putAll( sourceDominant ? target.getProperties() : source.getProperties() );
641 merged.putAll( sourceDominant ? source.getProperties() : target.getProperties() );
642 builder.properties( merged );
643 builder.location( "properties", InputLocation.merge( target.getLocation( "properties" ), source.getLocation( "properties" ), sourceDominant ) );
644 }
645 }
646 }
647 protected void mergeModelBase_DependencyManagement( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
648 {
649 DependencyManagement src = source.getDependencyManagement();
650 if ( src != null )
651 {
652 DependencyManagement tgt = target.getDependencyManagement();
653 if ( tgt == null )
654 {
655 tgt = DependencyManagement.newInstance( false );
656 }
657 DependencyManagement merged = mergeDependencyManagement( tgt, src, sourceDominant, context );
658 if ( merged == src )
659 {
660 builder.dependencyManagement( merged );
661 builder.location( "dependencyManagement", source.getLocation( "dependencyManagement" ) );
662 }
663 else if ( merged != tgt )
664 {
665 builder.dependencyManagement( merged );
666 builder.location( "dependencyManagement", InputLocation.merge( target.getLocation( "dependencyManagement" ), source.getLocation( "dependencyManagement" ), sourceDominant ) );
667 }
668 }
669 }
670 protected void mergeModelBase_Dependencies( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
671 {
672 if (deepMerge) {
673 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), getDependencyKey(),
674 ( t, s ) -> mergeDependency( t, s, sourceDominant, context ) ) );
675 } else {
676 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey() ) );
677 }
678 }
679 protected void mergeModelBase_Repositories( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
680 {
681 if (deepMerge) {
682 builder.repositories( merge( target.getRepositories(), source.getRepositories(), getRepositoryKey(),
683 ( t, s ) -> mergeRepository( t, s, sourceDominant, context ) ) );
684 } else {
685 builder.repositories( merge( target.getRepositories(), source.getRepositories(), sourceDominant, getRepositoryKey() ) );
686 }
687 }
688 protected void mergeModelBase_PluginRepositories( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
689 {
690 if (deepMerge) {
691 builder.pluginRepositories( merge( target.getPluginRepositories(), source.getPluginRepositories(), getRepositoryKey(),
692 ( t, s ) -> mergeRepository( t, s, sourceDominant, context ) ) );
693 } else {
694 builder.pluginRepositories( merge( target.getPluginRepositories(), source.getPluginRepositories(), sourceDominant, getRepositoryKey() ) );
695 }
696 }
697 protected void mergeModelBase_Reporting( ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context )
698 {
699 Reporting src = source.getReporting();
700 if ( src != null )
701 {
702 Reporting tgt = target.getReporting();
703 if ( tgt == null )
704 {
705 tgt = Reporting.newInstance( false );
706 }
707 Reporting merged = mergeReporting( tgt, src, sourceDominant, context );
708 if ( merged == src )
709 {
710 builder.reporting( merged );
711 builder.location( "reporting", source.getLocation( "reporting" ) );
712 }
713 else if ( merged != tgt )
714 {
715 builder.reporting( merged );
716 builder.location( "reporting", InputLocation.merge( target.getLocation( "reporting" ), source.getLocation( "reporting" ), sourceDominant ) );
717 }
718 }
719 }
720
721 protected PluginContainer mergePluginContainer( PluginContainer target, PluginContainer source, boolean sourceDominant, Map<Object, Object> context )
722 {
723 PluginContainer.Builder builder = PluginContainer.newBuilder( target );
724 mergePluginContainer( builder, target, source, sourceDominant, context );
725 return builder.build();
726 }
727
728 protected void mergePluginContainer( PluginContainer.Builder builder, PluginContainer target, PluginContainer source, boolean sourceDominant, Map<Object, Object> context )
729 {
730 mergePluginContainer_Plugins( builder, target, source, sourceDominant, context );
731 }
732
733 protected void mergePluginContainer_Plugins( PluginContainer.Builder builder, PluginContainer target, PluginContainer source, boolean sourceDominant, Map<Object, Object> context )
734 {
735 if (deepMerge) {
736 builder.plugins( merge( target.getPlugins(), source.getPlugins(), getPluginKey(),
737 ( t, s ) -> mergePlugin( t, s, sourceDominant, context ) ) );
738 } else {
739 builder.plugins( merge( target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey() ) );
740 }
741 }
742
743 protected PluginConfiguration mergePluginConfiguration( PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context )
744 {
745 PluginConfiguration.Builder builder = PluginConfiguration.newBuilder( target );
746 mergePluginConfiguration( builder, target, source, sourceDominant, context );
747 return builder.build();
748 }
749
750 protected void mergePluginConfiguration( PluginConfiguration.Builder builder, PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context )
751 {
752 mergePluginContainer( builder, target ,source, sourceDominant, context );
753 mergePluginConfiguration_PluginManagement( builder, target, source, sourceDominant, context );
754 }
755
756 protected void mergePluginConfiguration_Plugins( PluginConfiguration.Builder builder, PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context )
757 {
758 if (deepMerge) {
759 builder.plugins( merge( target.getPlugins(), source.getPlugins(), getPluginKey(),
760 ( t, s ) -> mergePlugin( t, s, sourceDominant, context ) ) );
761 } else {
762 builder.plugins( merge( target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey() ) );
763 }
764 }
765 protected void mergePluginConfiguration_PluginManagement( PluginConfiguration.Builder builder, PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context )
766 {
767 PluginManagement src = source.getPluginManagement();
768 if ( src != null )
769 {
770 PluginManagement tgt = target.getPluginManagement();
771 if ( tgt == null )
772 {
773 tgt = PluginManagement.newInstance( false );
774 }
775 PluginManagement merged = mergePluginManagement( tgt, src, sourceDominant, context );
776 if ( merged == src )
777 {
778 builder.pluginManagement( merged );
779 builder.location( "pluginManagement", source.getLocation( "pluginManagement" ) );
780 }
781 else if ( merged != tgt )
782 {
783 builder.pluginManagement( merged );
784 builder.location( "pluginManagement", InputLocation.merge( target.getLocation( "pluginManagement" ), source.getLocation( "pluginManagement" ), sourceDominant ) );
785 }
786 }
787 }
788
789 protected BuildBase mergeBuildBase( BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
790 {
791 BuildBase.Builder builder = BuildBase.newBuilder( target );
792 mergeBuildBase( builder, target, source, sourceDominant, context );
793 return builder.build();
794 }
795
796 protected void mergeBuildBase( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
797 {
798 mergePluginConfiguration( builder, target ,source, sourceDominant, context );
799 mergeBuildBase_DefaultGoal( builder, target, source, sourceDominant, context );
800 mergeBuildBase_Resources( builder, target, source, sourceDominant, context );
801 mergeBuildBase_TestResources( builder, target, source, sourceDominant, context );
802 mergeBuildBase_Directory( builder, target, source, sourceDominant, context );
803 mergeBuildBase_FinalName( builder, target, source, sourceDominant, context );
804 mergeBuildBase_Filters( builder, target, source, sourceDominant, context );
805 }
806
807 protected void mergeBuildBase_Plugins( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
808 {
809 if (deepMerge) {
810 builder.plugins( merge( target.getPlugins(), source.getPlugins(), getPluginKey(),
811 ( t, s ) -> mergePlugin( t, s, sourceDominant, context ) ) );
812 } else {
813 builder.plugins( merge( target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey() ) );
814 }
815 }
816 protected void mergeBuildBase_PluginManagement( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
817 {
818 PluginManagement src = source.getPluginManagement();
819 if ( src != null )
820 {
821 PluginManagement tgt = target.getPluginManagement();
822 if ( tgt == null )
823 {
824 tgt = PluginManagement.newInstance( false );
825 }
826 PluginManagement merged = mergePluginManagement( tgt, src, sourceDominant, context );
827 if ( merged == src )
828 {
829 builder.pluginManagement( merged );
830 builder.location( "pluginManagement", source.getLocation( "pluginManagement" ) );
831 }
832 else if ( merged != tgt )
833 {
834 builder.pluginManagement( merged );
835 builder.location( "pluginManagement", InputLocation.merge( target.getLocation( "pluginManagement" ), source.getLocation( "pluginManagement" ), sourceDominant ) );
836 }
837 }
838 }
839 protected void mergeBuildBase_DefaultGoal( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
840 {
841 String src = source.getDefaultGoal();
842 String tgt = target.getDefaultGoal();
843 if ( src != null && ( sourceDominant || tgt == null ) )
844 {
845 builder.defaultGoal( src );
846 builder.location( "defaultGoal", source.getLocation( "defaultGoal" ) );
847 }
848 }
849 protected void mergeBuildBase_Resources( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
850 {
851 if (deepMerge) {
852 builder.resources( merge( target.getResources(), source.getResources(), getResourceKey(),
853 ( t, s ) -> mergeResource( t, s, sourceDominant, context ) ) );
854 } else {
855 builder.resources( merge( target.getResources(), source.getResources(), sourceDominant, getResourceKey() ) );
856 }
857 }
858 protected void mergeBuildBase_TestResources( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
859 {
860 if (deepMerge) {
861 builder.testResources( merge( target.getTestResources(), source.getTestResources(), getResourceKey(),
862 ( t, s ) -> mergeResource( t, s, sourceDominant, context ) ) );
863 } else {
864 builder.testResources( merge( target.getTestResources(), source.getTestResources(), sourceDominant, getResourceKey() ) );
865 }
866 }
867 protected void mergeBuildBase_Directory( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
868 {
869 String src = source.getDirectory();
870 String tgt = target.getDirectory();
871 if ( src != null && ( sourceDominant || tgt == null ) )
872 {
873 builder.directory( src );
874 builder.location( "directory", source.getLocation( "directory" ) );
875 }
876 }
877 protected void mergeBuildBase_FinalName( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
878 {
879 String src = source.getFinalName();
880 String tgt = target.getFinalName();
881 if ( src != null && ( sourceDominant || tgt == null ) )
882 {
883 builder.finalName( src );
884 builder.location( "finalName", source.getLocation( "finalName" ) );
885 }
886 }
887 protected void mergeBuildBase_Filters( BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context )
888 {
889 builder.filters( merge( target.getFilters(), source.getFilters(), sourceDominant, e -> e ) );
890 }
891
892 protected Build mergeBuild( Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
893 {
894 Build.Builder builder = Build.newBuilder( target );
895 mergeBuild( builder, target, source, sourceDominant, context );
896 return builder.build();
897 }
898
899 protected void mergeBuild( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
900 {
901 mergeBuildBase( builder, target ,source, sourceDominant, context );
902 mergeBuild_SourceDirectory( builder, target, source, sourceDominant, context );
903 mergeBuild_ScriptSourceDirectory( builder, target, source, sourceDominant, context );
904 mergeBuild_TestSourceDirectory( builder, target, source, sourceDominant, context );
905 mergeBuild_OutputDirectory( builder, target, source, sourceDominant, context );
906 mergeBuild_TestOutputDirectory( builder, target, source, sourceDominant, context );
907 mergeBuild_Extensions( builder, target, source, sourceDominant, context );
908 }
909
910 protected void mergeBuild_Plugins( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
911 {
912 if (deepMerge) {
913 builder.plugins( merge( target.getPlugins(), source.getPlugins(), getPluginKey(),
914 ( t, s ) -> mergePlugin( t, s, sourceDominant, context ) ) );
915 } else {
916 builder.plugins( merge( target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey() ) );
917 }
918 }
919 protected void mergeBuild_PluginManagement( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
920 {
921 PluginManagement src = source.getPluginManagement();
922 if ( src != null )
923 {
924 PluginManagement tgt = target.getPluginManagement();
925 if ( tgt == null )
926 {
927 tgt = PluginManagement.newInstance( false );
928 }
929 PluginManagement merged = mergePluginManagement( tgt, src, sourceDominant, context );
930 if ( merged == src )
931 {
932 builder.pluginManagement( merged );
933 builder.location( "pluginManagement", source.getLocation( "pluginManagement" ) );
934 }
935 else if ( merged != tgt )
936 {
937 builder.pluginManagement( merged );
938 builder.location( "pluginManagement", InputLocation.merge( target.getLocation( "pluginManagement" ), source.getLocation( "pluginManagement" ), sourceDominant ) );
939 }
940 }
941 }
942 protected void mergeBuild_DefaultGoal( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
943 {
944 String src = source.getDefaultGoal();
945 String tgt = target.getDefaultGoal();
946 if ( src != null && ( sourceDominant || tgt == null ) )
947 {
948 builder.defaultGoal( src );
949 builder.location( "defaultGoal", source.getLocation( "defaultGoal" ) );
950 }
951 }
952 protected void mergeBuild_Resources( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
953 {
954 if (deepMerge) {
955 builder.resources( merge( target.getResources(), source.getResources(), getResourceKey(),
956 ( t, s ) -> mergeResource( t, s, sourceDominant, context ) ) );
957 } else {
958 builder.resources( merge( target.getResources(), source.getResources(), sourceDominant, getResourceKey() ) );
959 }
960 }
961 protected void mergeBuild_TestResources( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
962 {
963 if (deepMerge) {
964 builder.testResources( merge( target.getTestResources(), source.getTestResources(), getResourceKey(),
965 ( t, s ) -> mergeResource( t, s, sourceDominant, context ) ) );
966 } else {
967 builder.testResources( merge( target.getTestResources(), source.getTestResources(), sourceDominant, getResourceKey() ) );
968 }
969 }
970 protected void mergeBuild_Directory( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
971 {
972 String src = source.getDirectory();
973 String tgt = target.getDirectory();
974 if ( src != null && ( sourceDominant || tgt == null ) )
975 {
976 builder.directory( src );
977 builder.location( "directory", source.getLocation( "directory" ) );
978 }
979 }
980 protected void mergeBuild_FinalName( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
981 {
982 String src = source.getFinalName();
983 String tgt = target.getFinalName();
984 if ( src != null && ( sourceDominant || tgt == null ) )
985 {
986 builder.finalName( src );
987 builder.location( "finalName", source.getLocation( "finalName" ) );
988 }
989 }
990 protected void mergeBuild_Filters( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
991 {
992 builder.filters( merge( target.getFilters(), source.getFilters(), sourceDominant, e -> e ) );
993 }
994 protected void mergeBuild_SourceDirectory( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
995 {
996 String src = source.getSourceDirectory();
997 String tgt = target.getSourceDirectory();
998 if ( src != null && ( sourceDominant || tgt == null ) )
999 {
1000 builder.sourceDirectory( src );
1001 builder.location( "sourceDirectory", source.getLocation( "sourceDirectory" ) );
1002 }
1003 }
1004 protected void mergeBuild_ScriptSourceDirectory( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
1005 {
1006 String src = source.getScriptSourceDirectory();
1007 String tgt = target.getScriptSourceDirectory();
1008 if ( src != null && ( sourceDominant || tgt == null ) )
1009 {
1010 builder.scriptSourceDirectory( src );
1011 builder.location( "scriptSourceDirectory", source.getLocation( "scriptSourceDirectory" ) );
1012 }
1013 }
1014 protected void mergeBuild_TestSourceDirectory( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
1015 {
1016 String src = source.getTestSourceDirectory();
1017 String tgt = target.getTestSourceDirectory();
1018 if ( src != null && ( sourceDominant || tgt == null ) )
1019 {
1020 builder.testSourceDirectory( src );
1021 builder.location( "testSourceDirectory", source.getLocation( "testSourceDirectory" ) );
1022 }
1023 }
1024 protected void mergeBuild_OutputDirectory( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
1025 {
1026 String src = source.getOutputDirectory();
1027 String tgt = target.getOutputDirectory();
1028 if ( src != null && ( sourceDominant || tgt == null ) )
1029 {
1030 builder.outputDirectory( src );
1031 builder.location( "outputDirectory", source.getLocation( "outputDirectory" ) );
1032 }
1033 }
1034 protected void mergeBuild_TestOutputDirectory( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
1035 {
1036 String src = source.getTestOutputDirectory();
1037 String tgt = target.getTestOutputDirectory();
1038 if ( src != null && ( sourceDominant || tgt == null ) )
1039 {
1040 builder.testOutputDirectory( src );
1041 builder.location( "testOutputDirectory", source.getLocation( "testOutputDirectory" ) );
1042 }
1043 }
1044 protected void mergeBuild_Extensions( Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context )
1045 {
1046 if (deepMerge) {
1047 builder.extensions( merge( target.getExtensions(), source.getExtensions(), getExtensionKey(),
1048 ( t, s ) -> mergeExtension( t, s, sourceDominant, context ) ) );
1049 } else {
1050 builder.extensions( merge( target.getExtensions(), source.getExtensions(), sourceDominant, getExtensionKey() ) );
1051 }
1052 }
1053
1054 protected CiManagement mergeCiManagement( CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context )
1055 {
1056 CiManagement.Builder builder = CiManagement.newBuilder( target );
1057 mergeCiManagement( builder, target, source, sourceDominant, context );
1058 return builder.build();
1059 }
1060
1061 protected void mergeCiManagement( CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context )
1062 {
1063 mergeCiManagement_System( builder, target, source, sourceDominant, context );
1064 mergeCiManagement_Url( builder, target, source, sourceDominant, context );
1065 mergeCiManagement_Notifiers( builder, target, source, sourceDominant, context );
1066 }
1067
1068 protected void mergeCiManagement_System( CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context )
1069 {
1070 String src = source.getSystem();
1071 String tgt = target.getSystem();
1072 if ( src != null && ( sourceDominant || tgt == null ) )
1073 {
1074 builder.system( src );
1075 builder.location( "system", source.getLocation( "system" ) );
1076 }
1077 }
1078 protected void mergeCiManagement_Url( CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context )
1079 {
1080 String src = source.getUrl();
1081 String tgt = target.getUrl();
1082 if ( src != null && ( sourceDominant || tgt == null ) )
1083 {
1084 builder.url( src );
1085 builder.location( "url", source.getLocation( "url" ) );
1086 }
1087 }
1088 protected void mergeCiManagement_Notifiers( CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context )
1089 {
1090 if (deepMerge) {
1091 builder.notifiers( merge( target.getNotifiers(), source.getNotifiers(), getNotifierKey(),
1092 ( t, s ) -> mergeNotifier( t, s, sourceDominant, context ) ) );
1093 } else {
1094 builder.notifiers( merge( target.getNotifiers(), source.getNotifiers(), sourceDominant, getNotifierKey() ) );
1095 }
1096 }
1097
1098 protected Notifier mergeNotifier( Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1099 {
1100 Notifier.Builder builder = Notifier.newBuilder( target );
1101 mergeNotifier( builder, target, source, sourceDominant, context );
1102 return builder.build();
1103 }
1104
1105 protected void mergeNotifier( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1106 {
1107 mergeNotifier_Type( builder, target, source, sourceDominant, context );
1108 mergeNotifier_SendOnError( builder, target, source, sourceDominant, context );
1109 mergeNotifier_SendOnFailure( builder, target, source, sourceDominant, context );
1110 mergeNotifier_SendOnSuccess( builder, target, source, sourceDominant, context );
1111 mergeNotifier_SendOnWarning( builder, target, source, sourceDominant, context );
1112 mergeNotifier_Address( builder, target, source, sourceDominant, context );
1113 mergeNotifier_Configuration( builder, target, source, sourceDominant, context );
1114 }
1115
1116 protected void mergeNotifier_Type( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1117 {
1118 String src = source.getType();
1119 String tgt = target.getType();
1120 if ( src != null && ( sourceDominant || tgt == null ) )
1121 {
1122 builder.type( src );
1123 builder.location( "type", source.getLocation( "type" ) );
1124 }
1125 }
1126 protected void mergeNotifier_SendOnError( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1127 {
1128 if ( sourceDominant )
1129 {
1130 builder.sendOnError( source.isSendOnError() );
1131 }
1132 }
1133 protected void mergeNotifier_SendOnFailure( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1134 {
1135 if ( sourceDominant )
1136 {
1137 builder.sendOnFailure( source.isSendOnFailure() );
1138 }
1139 }
1140 protected void mergeNotifier_SendOnSuccess( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1141 {
1142 if ( sourceDominant )
1143 {
1144 builder.sendOnSuccess( source.isSendOnSuccess() );
1145 }
1146 }
1147 protected void mergeNotifier_SendOnWarning( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1148 {
1149 if ( sourceDominant )
1150 {
1151 builder.sendOnWarning( source.isSendOnWarning() );
1152 }
1153 }
1154 protected void mergeNotifier_Address( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1155 {
1156 String src = source.getAddress();
1157 String tgt = target.getAddress();
1158 if ( src != null && ( sourceDominant || tgt == null ) )
1159 {
1160 builder.address( src );
1161 builder.location( "address", source.getLocation( "address" ) );
1162 }
1163 }
1164 protected void mergeNotifier_Configuration( Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context )
1165 {
1166 Map<String, String> src = source.getConfiguration();
1167 if ( !src.isEmpty() )
1168 {
1169 Map<String, String> tgt = target.getConfiguration();
1170 if ( tgt.isEmpty() )
1171 {
1172 builder.configuration( src );
1173 builder.location( "configuration", source.getLocation( "configuration" ) );
1174 }
1175 else
1176 {
1177 Map<String, String> merged = new HashMap<>();
1178 merged.putAll( sourceDominant ? target.getConfiguration() : source.getConfiguration() );
1179 merged.putAll( sourceDominant ? source.getConfiguration() : target.getConfiguration() );
1180 builder.configuration( merged );
1181 builder.location( "configuration", InputLocation.merge( target.getLocation( "configuration" ), source.getLocation( "configuration" ), sourceDominant ) );
1182 }
1183 }
1184 }
1185
1186 protected Contributor mergeContributor( Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1187 {
1188 Contributor.Builder builder = Contributor.newBuilder( target );
1189 mergeContributor( builder, target, source, sourceDominant, context );
1190 return builder.build();
1191 }
1192
1193 protected void mergeContributor( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1194 {
1195 mergeContributor_Name( builder, target, source, sourceDominant, context );
1196 mergeContributor_Email( builder, target, source, sourceDominant, context );
1197 mergeContributor_Url( builder, target, source, sourceDominant, context );
1198 mergeContributor_Organization( builder, target, source, sourceDominant, context );
1199 mergeContributor_OrganizationUrl( builder, target, source, sourceDominant, context );
1200 mergeContributor_Roles( builder, target, source, sourceDominant, context );
1201 mergeContributor_Timezone( builder, target, source, sourceDominant, context );
1202 mergeContributor_Properties( builder, target, source, sourceDominant, context );
1203 }
1204
1205 protected void mergeContributor_Name( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1206 {
1207 String src = source.getName();
1208 String tgt = target.getName();
1209 if ( src != null && ( sourceDominant || tgt == null ) )
1210 {
1211 builder.name( src );
1212 builder.location( "name", source.getLocation( "name" ) );
1213 }
1214 }
1215 protected void mergeContributor_Email( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1216 {
1217 String src = source.getEmail();
1218 String tgt = target.getEmail();
1219 if ( src != null && ( sourceDominant || tgt == null ) )
1220 {
1221 builder.email( src );
1222 builder.location( "email", source.getLocation( "email" ) );
1223 }
1224 }
1225 protected void mergeContributor_Url( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1226 {
1227 String src = source.getUrl();
1228 String tgt = target.getUrl();
1229 if ( src != null && ( sourceDominant || tgt == null ) )
1230 {
1231 builder.url( src );
1232 builder.location( "url", source.getLocation( "url" ) );
1233 }
1234 }
1235 protected void mergeContributor_Organization( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1236 {
1237 String src = source.getOrganization();
1238 String tgt = target.getOrganization();
1239 if ( src != null && ( sourceDominant || tgt == null ) )
1240 {
1241 builder.organization( src );
1242 builder.location( "organization", source.getLocation( "organization" ) );
1243 }
1244 }
1245 protected void mergeContributor_OrganizationUrl( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1246 {
1247 String src = source.getOrganizationUrl();
1248 String tgt = target.getOrganizationUrl();
1249 if ( src != null && ( sourceDominant || tgt == null ) )
1250 {
1251 builder.organizationUrl( src );
1252 builder.location( "organizationUrl", source.getLocation( "organizationUrl" ) );
1253 }
1254 }
1255 protected void mergeContributor_Roles( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1256 {
1257 builder.roles( merge( target.getRoles(), source.getRoles(), sourceDominant, e -> e ) );
1258 }
1259 protected void mergeContributor_Timezone( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1260 {
1261 String src = source.getTimezone();
1262 String tgt = target.getTimezone();
1263 if ( src != null && ( sourceDominant || tgt == null ) )
1264 {
1265 builder.timezone( src );
1266 builder.location( "timezone", source.getLocation( "timezone" ) );
1267 }
1268 }
1269 protected void mergeContributor_Properties( Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context )
1270 {
1271 Map<String, String> src = source.getProperties();
1272 if ( !src.isEmpty() )
1273 {
1274 Map<String, String> tgt = target.getProperties();
1275 if ( tgt.isEmpty() )
1276 {
1277 builder.properties( src );
1278 builder.location( "properties", source.getLocation( "properties" ) );
1279 }
1280 else
1281 {
1282 Map<String, String> merged = new HashMap<>();
1283 merged.putAll( sourceDominant ? target.getProperties() : source.getProperties() );
1284 merged.putAll( sourceDominant ? source.getProperties() : target.getProperties() );
1285 builder.properties( merged );
1286 builder.location( "properties", InputLocation.merge( target.getLocation( "properties" ), source.getLocation( "properties" ), sourceDominant ) );
1287 }
1288 }
1289 }
1290
1291 protected Dependency mergeDependency( Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1292 {
1293 Dependency.Builder builder = Dependency.newBuilder( target );
1294 mergeDependency( builder, target, source, sourceDominant, context );
1295 return builder.build();
1296 }
1297
1298 protected void mergeDependency( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1299 {
1300 mergeDependency_GroupId( builder, target, source, sourceDominant, context );
1301 mergeDependency_ArtifactId( builder, target, source, sourceDominant, context );
1302 mergeDependency_Version( builder, target, source, sourceDominant, context );
1303 mergeDependency_Type( builder, target, source, sourceDominant, context );
1304 mergeDependency_Classifier( builder, target, source, sourceDominant, context );
1305 mergeDependency_Scope( builder, target, source, sourceDominant, context );
1306 mergeDependency_SystemPath( builder, target, source, sourceDominant, context );
1307 mergeDependency_Exclusions( builder, target, source, sourceDominant, context );
1308 mergeDependency_Optional( builder, target, source, sourceDominant, context );
1309 }
1310
1311 protected void mergeDependency_GroupId( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1312 {
1313 String src = source.getGroupId();
1314 String tgt = target.getGroupId();
1315 if ( src != null && ( sourceDominant || tgt == null ) )
1316 {
1317 builder.groupId( src );
1318 builder.location( "groupId", source.getLocation( "groupId" ) );
1319 }
1320 }
1321 protected void mergeDependency_ArtifactId( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1322 {
1323 String src = source.getArtifactId();
1324 String tgt = target.getArtifactId();
1325 if ( src != null && ( sourceDominant || tgt == null ) )
1326 {
1327 builder.artifactId( src );
1328 builder.location( "artifactId", source.getLocation( "artifactId" ) );
1329 }
1330 }
1331 protected void mergeDependency_Version( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1332 {
1333 String src = source.getVersion();
1334 String tgt = target.getVersion();
1335 if ( src != null && ( sourceDominant || tgt == null ) )
1336 {
1337 builder.version( src );
1338 builder.location( "version", source.getLocation( "version" ) );
1339 }
1340 }
1341 protected void mergeDependency_Type( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1342 {
1343 String src = source.getType();
1344 String tgt = target.getType();
1345 if ( src != null && ( sourceDominant || tgt == null ) )
1346 {
1347 builder.type( src );
1348 builder.location( "type", source.getLocation( "type" ) );
1349 }
1350 }
1351 protected void mergeDependency_Classifier( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1352 {
1353 String src = source.getClassifier();
1354 String tgt = target.getClassifier();
1355 if ( src != null && ( sourceDominant || tgt == null ) )
1356 {
1357 builder.classifier( src );
1358 builder.location( "classifier", source.getLocation( "classifier" ) );
1359 }
1360 }
1361 protected void mergeDependency_Scope( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1362 {
1363 String src = source.getScope();
1364 String tgt = target.getScope();
1365 if ( src != null && ( sourceDominant || tgt == null ) )
1366 {
1367 builder.scope( src );
1368 builder.location( "scope", source.getLocation( "scope" ) );
1369 }
1370 }
1371 protected void mergeDependency_SystemPath( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1372 {
1373 String src = source.getSystemPath();
1374 String tgt = target.getSystemPath();
1375 if ( src != null && ( sourceDominant || tgt == null ) )
1376 {
1377 builder.systemPath( src );
1378 builder.location( "systemPath", source.getLocation( "systemPath" ) );
1379 }
1380 }
1381 protected void mergeDependency_Exclusions( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1382 {
1383 if (deepMerge) {
1384 builder.exclusions( merge( target.getExclusions(), source.getExclusions(), getExclusionKey(),
1385 ( t, s ) -> mergeExclusion( t, s, sourceDominant, context ) ) );
1386 } else {
1387 builder.exclusions( merge( target.getExclusions(), source.getExclusions(), sourceDominant, getExclusionKey() ) );
1388 }
1389 }
1390 protected void mergeDependency_Optional( Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context )
1391 {
1392 String src = source.getOptional();
1393 String tgt = target.getOptional();
1394 if ( src != null && ( sourceDominant || tgt == null ) )
1395 {
1396 builder.optional( src );
1397 builder.location( "optional", source.getLocation( "optional" ) );
1398 }
1399 }
1400
1401 protected Developer mergeDeveloper( Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1402 {
1403 Developer.Builder builder = Developer.newBuilder( target );
1404 mergeDeveloper( builder, target, source, sourceDominant, context );
1405 return builder.build();
1406 }
1407
1408 protected void mergeDeveloper( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1409 {
1410 mergeContributor( builder, target ,source, sourceDominant, context );
1411 mergeDeveloper_Id( builder, target, source, sourceDominant, context );
1412 }
1413
1414 protected void mergeDeveloper_Name( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1415 {
1416 String src = source.getName();
1417 String tgt = target.getName();
1418 if ( src != null && ( sourceDominant || tgt == null ) )
1419 {
1420 builder.name( src );
1421 builder.location( "name", source.getLocation( "name" ) );
1422 }
1423 }
1424 protected void mergeDeveloper_Email( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1425 {
1426 String src = source.getEmail();
1427 String tgt = target.getEmail();
1428 if ( src != null && ( sourceDominant || tgt == null ) )
1429 {
1430 builder.email( src );
1431 builder.location( "email", source.getLocation( "email" ) );
1432 }
1433 }
1434 protected void mergeDeveloper_Url( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1435 {
1436 String src = source.getUrl();
1437 String tgt = target.getUrl();
1438 if ( src != null && ( sourceDominant || tgt == null ) )
1439 {
1440 builder.url( src );
1441 builder.location( "url", source.getLocation( "url" ) );
1442 }
1443 }
1444 protected void mergeDeveloper_Organization( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1445 {
1446 String src = source.getOrganization();
1447 String tgt = target.getOrganization();
1448 if ( src != null && ( sourceDominant || tgt == null ) )
1449 {
1450 builder.organization( src );
1451 builder.location( "organization", source.getLocation( "organization" ) );
1452 }
1453 }
1454 protected void mergeDeveloper_OrganizationUrl( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1455 {
1456 String src = source.getOrganizationUrl();
1457 String tgt = target.getOrganizationUrl();
1458 if ( src != null && ( sourceDominant || tgt == null ) )
1459 {
1460 builder.organizationUrl( src );
1461 builder.location( "organizationUrl", source.getLocation( "organizationUrl" ) );
1462 }
1463 }
1464 protected void mergeDeveloper_Roles( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1465 {
1466 builder.roles( merge( target.getRoles(), source.getRoles(), sourceDominant, e -> e ) );
1467 }
1468 protected void mergeDeveloper_Timezone( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1469 {
1470 String src = source.getTimezone();
1471 String tgt = target.getTimezone();
1472 if ( src != null && ( sourceDominant || tgt == null ) )
1473 {
1474 builder.timezone( src );
1475 builder.location( "timezone", source.getLocation( "timezone" ) );
1476 }
1477 }
1478 protected void mergeDeveloper_Properties( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1479 {
1480 Map<String, String> src = source.getProperties();
1481 if ( !src.isEmpty() )
1482 {
1483 Map<String, String> tgt = target.getProperties();
1484 if ( tgt.isEmpty() )
1485 {
1486 builder.properties( src );
1487 builder.location( "properties", source.getLocation( "properties" ) );
1488 }
1489 else
1490 {
1491 Map<String, String> merged = new HashMap<>();
1492 merged.putAll( sourceDominant ? target.getProperties() : source.getProperties() );
1493 merged.putAll( sourceDominant ? source.getProperties() : target.getProperties() );
1494 builder.properties( merged );
1495 builder.location( "properties", InputLocation.merge( target.getLocation( "properties" ), source.getLocation( "properties" ), sourceDominant ) );
1496 }
1497 }
1498 }
1499 protected void mergeDeveloper_Id( Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context )
1500 {
1501 String src = source.getId();
1502 String tgt = target.getId();
1503 if ( src != null && ( sourceDominant || tgt == null ) )
1504 {
1505 builder.id( src );
1506 builder.location( "id", source.getLocation( "id" ) );
1507 }
1508 }
1509
1510 protected Exclusion mergeExclusion( Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context )
1511 {
1512 Exclusion.Builder builder = Exclusion.newBuilder( target );
1513 mergeExclusion( builder, target, source, sourceDominant, context );
1514 return builder.build();
1515 }
1516
1517 protected void mergeExclusion( Exclusion.Builder builder, Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context )
1518 {
1519 mergeExclusion_GroupId( builder, target, source, sourceDominant, context );
1520 mergeExclusion_ArtifactId( builder, target, source, sourceDominant, context );
1521 }
1522
1523 protected void mergeExclusion_GroupId( Exclusion.Builder builder, Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context )
1524 {
1525 String src = source.getGroupId();
1526 String tgt = target.getGroupId();
1527 if ( src != null && ( sourceDominant || tgt == null ) )
1528 {
1529 builder.groupId( src );
1530 builder.location( "groupId", source.getLocation( "groupId" ) );
1531 }
1532 }
1533 protected void mergeExclusion_ArtifactId( Exclusion.Builder builder, Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context )
1534 {
1535 String src = source.getArtifactId();
1536 String tgt = target.getArtifactId();
1537 if ( src != null && ( sourceDominant || tgt == null ) )
1538 {
1539 builder.artifactId( src );
1540 builder.location( "artifactId", source.getLocation( "artifactId" ) );
1541 }
1542 }
1543
1544 protected IssueManagement mergeIssueManagement( IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context )
1545 {
1546 IssueManagement.Builder builder = IssueManagement.newBuilder( target );
1547 mergeIssueManagement( builder, target, source, sourceDominant, context );
1548 return builder.build();
1549 }
1550
1551 protected void mergeIssueManagement( IssueManagement.Builder builder, IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context )
1552 {
1553 mergeIssueManagement_System( builder, target, source, sourceDominant, context );
1554 mergeIssueManagement_Url( builder, target, source, sourceDominant, context );
1555 }
1556
1557 protected void mergeIssueManagement_System( IssueManagement.Builder builder, IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context )
1558 {
1559 String src = source.getSystem();
1560 String tgt = target.getSystem();
1561 if ( src != null && ( sourceDominant || tgt == null ) )
1562 {
1563 builder.system( src );
1564 builder.location( "system", source.getLocation( "system" ) );
1565 }
1566 }
1567 protected void mergeIssueManagement_Url( IssueManagement.Builder builder, IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context )
1568 {
1569 String src = source.getUrl();
1570 String tgt = target.getUrl();
1571 if ( src != null && ( sourceDominant || tgt == null ) )
1572 {
1573 builder.url( src );
1574 builder.location( "url", source.getLocation( "url" ) );
1575 }
1576 }
1577
1578 protected DistributionManagement mergeDistributionManagement( DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1579 {
1580 DistributionManagement.Builder builder = DistributionManagement.newBuilder( target );
1581 mergeDistributionManagement( builder, target, source, sourceDominant, context );
1582 return builder.build();
1583 }
1584
1585 protected void mergeDistributionManagement( DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1586 {
1587 mergeDistributionManagement_Repository( builder, target, source, sourceDominant, context );
1588 mergeDistributionManagement_SnapshotRepository( builder, target, source, sourceDominant, context );
1589 mergeDistributionManagement_Site( builder, target, source, sourceDominant, context );
1590 mergeDistributionManagement_DownloadUrl( builder, target, source, sourceDominant, context );
1591 mergeDistributionManagement_Relocation( builder, target, source, sourceDominant, context );
1592 mergeDistributionManagement_Status( builder, target, source, sourceDominant, context );
1593 }
1594
1595 protected void mergeDistributionManagement_Repository( DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1596 {
1597 DeploymentRepository src = source.getRepository();
1598 if ( src != null )
1599 {
1600 DeploymentRepository tgt = target.getRepository();
1601 if ( tgt == null )
1602 {
1603 tgt = DeploymentRepository.newInstance( false );
1604 }
1605 DeploymentRepository merged = mergeDeploymentRepository( tgt, src, sourceDominant, context );
1606 if ( merged == src )
1607 {
1608 builder.repository( merged );
1609 builder.location( "repository", source.getLocation( "repository" ) );
1610 }
1611 else if ( merged != tgt )
1612 {
1613 builder.repository( merged );
1614 builder.location( "repository", InputLocation.merge( target.getLocation( "repository" ), source.getLocation( "repository" ), sourceDominant ) );
1615 }
1616 }
1617 }
1618 protected void mergeDistributionManagement_SnapshotRepository( DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1619 {
1620 DeploymentRepository src = source.getSnapshotRepository();
1621 if ( src != null )
1622 {
1623 DeploymentRepository tgt = target.getSnapshotRepository();
1624 if ( tgt == null )
1625 {
1626 tgt = DeploymentRepository.newInstance( false );
1627 }
1628 DeploymentRepository merged = mergeDeploymentRepository( tgt, src, sourceDominant, context );
1629 if ( merged == src )
1630 {
1631 builder.snapshotRepository( merged );
1632 builder.location( "snapshotRepository", source.getLocation( "snapshotRepository" ) );
1633 }
1634 else if ( merged != tgt )
1635 {
1636 builder.snapshotRepository( merged );
1637 builder.location( "snapshotRepository", InputLocation.merge( target.getLocation( "snapshotRepository" ), source.getLocation( "snapshotRepository" ), sourceDominant ) );
1638 }
1639 }
1640 }
1641 protected void mergeDistributionManagement_Site( DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1642 {
1643 Site src = source.getSite();
1644 if ( src != null )
1645 {
1646 Site tgt = target.getSite();
1647 if ( tgt == null )
1648 {
1649 tgt = Site.newInstance( false );
1650 }
1651 Site merged = mergeSite( tgt, src, sourceDominant, context );
1652 if ( merged == src )
1653 {
1654 builder.site( merged );
1655 builder.location( "site", source.getLocation( "site" ) );
1656 }
1657 else if ( merged != tgt )
1658 {
1659 builder.site( merged );
1660 builder.location( "site", InputLocation.merge( target.getLocation( "site" ), source.getLocation( "site" ), sourceDominant ) );
1661 }
1662 }
1663 }
1664 protected void mergeDistributionManagement_DownloadUrl( DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1665 {
1666 String src = source.getDownloadUrl();
1667 String tgt = target.getDownloadUrl();
1668 if ( src != null && ( sourceDominant || tgt == null ) )
1669 {
1670 builder.downloadUrl( src );
1671 builder.location( "downloadUrl", source.getLocation( "downloadUrl" ) );
1672 }
1673 }
1674 protected void mergeDistributionManagement_Relocation( DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1675 {
1676 Relocation src = source.getRelocation();
1677 if ( src != null )
1678 {
1679 Relocation tgt = target.getRelocation();
1680 if ( tgt == null )
1681 {
1682 tgt = Relocation.newInstance( false );
1683 }
1684 Relocation merged = mergeRelocation( tgt, src, sourceDominant, context );
1685 if ( merged == src )
1686 {
1687 builder.relocation( merged );
1688 builder.location( "relocation", source.getLocation( "relocation" ) );
1689 }
1690 else if ( merged != tgt )
1691 {
1692 builder.relocation( merged );
1693 builder.location( "relocation", InputLocation.merge( target.getLocation( "relocation" ), source.getLocation( "relocation" ), sourceDominant ) );
1694 }
1695 }
1696 }
1697 protected void mergeDistributionManagement_Status( DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context )
1698 {
1699 String src = source.getStatus();
1700 String tgt = target.getStatus();
1701 if ( src != null && ( sourceDominant || tgt == null ) )
1702 {
1703 builder.status( src );
1704 builder.location( "status", source.getLocation( "status" ) );
1705 }
1706 }
1707
1708 protected License mergeLicense( License target, License source, boolean sourceDominant, Map<Object, Object> context )
1709 {
1710 License.Builder builder = License.newBuilder( target );
1711 mergeLicense( builder, target, source, sourceDominant, context );
1712 return builder.build();
1713 }
1714
1715 protected void mergeLicense( License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context )
1716 {
1717 mergeLicense_Name( builder, target, source, sourceDominant, context );
1718 mergeLicense_Url( builder, target, source, sourceDominant, context );
1719 mergeLicense_Distribution( builder, target, source, sourceDominant, context );
1720 mergeLicense_Comments( builder, target, source, sourceDominant, context );
1721 }
1722
1723 protected void mergeLicense_Name( License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context )
1724 {
1725 String src = source.getName();
1726 String tgt = target.getName();
1727 if ( src != null && ( sourceDominant || tgt == null ) )
1728 {
1729 builder.name( src );
1730 builder.location( "name", source.getLocation( "name" ) );
1731 }
1732 }
1733 protected void mergeLicense_Url( License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context )
1734 {
1735 String src = source.getUrl();
1736 String tgt = target.getUrl();
1737 if ( src != null && ( sourceDominant || tgt == null ) )
1738 {
1739 builder.url( src );
1740 builder.location( "url", source.getLocation( "url" ) );
1741 }
1742 }
1743 protected void mergeLicense_Distribution( License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context )
1744 {
1745 String src = source.getDistribution();
1746 String tgt = target.getDistribution();
1747 if ( src != null && ( sourceDominant || tgt == null ) )
1748 {
1749 builder.distribution( src );
1750 builder.location( "distribution", source.getLocation( "distribution" ) );
1751 }
1752 }
1753 protected void mergeLicense_Comments( License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context )
1754 {
1755 String src = source.getComments();
1756 String tgt = target.getComments();
1757 if ( src != null && ( sourceDominant || tgt == null ) )
1758 {
1759 builder.comments( src );
1760 builder.location( "comments", source.getLocation( "comments" ) );
1761 }
1762 }
1763
1764 protected MailingList mergeMailingList( MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1765 {
1766 MailingList.Builder builder = MailingList.newBuilder( target );
1767 mergeMailingList( builder, target, source, sourceDominant, context );
1768 return builder.build();
1769 }
1770
1771 protected void mergeMailingList( MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1772 {
1773 mergeMailingList_Name( builder, target, source, sourceDominant, context );
1774 mergeMailingList_Subscribe( builder, target, source, sourceDominant, context );
1775 mergeMailingList_Unsubscribe( builder, target, source, sourceDominant, context );
1776 mergeMailingList_Post( builder, target, source, sourceDominant, context );
1777 mergeMailingList_Archive( builder, target, source, sourceDominant, context );
1778 mergeMailingList_OtherArchives( builder, target, source, sourceDominant, context );
1779 }
1780
1781 protected void mergeMailingList_Name( MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1782 {
1783 String src = source.getName();
1784 String tgt = target.getName();
1785 if ( src != null && ( sourceDominant || tgt == null ) )
1786 {
1787 builder.name( src );
1788 builder.location( "name", source.getLocation( "name" ) );
1789 }
1790 }
1791 protected void mergeMailingList_Subscribe( MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1792 {
1793 String src = source.getSubscribe();
1794 String tgt = target.getSubscribe();
1795 if ( src != null && ( sourceDominant || tgt == null ) )
1796 {
1797 builder.subscribe( src );
1798 builder.location( "subscribe", source.getLocation( "subscribe" ) );
1799 }
1800 }
1801 protected void mergeMailingList_Unsubscribe( MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1802 {
1803 String src = source.getUnsubscribe();
1804 String tgt = target.getUnsubscribe();
1805 if ( src != null && ( sourceDominant || tgt == null ) )
1806 {
1807 builder.unsubscribe( src );
1808 builder.location( "unsubscribe", source.getLocation( "unsubscribe" ) );
1809 }
1810 }
1811 protected void mergeMailingList_Post( MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1812 {
1813 String src = source.getPost();
1814 String tgt = target.getPost();
1815 if ( src != null && ( sourceDominant || tgt == null ) )
1816 {
1817 builder.post( src );
1818 builder.location( "post", source.getLocation( "post" ) );
1819 }
1820 }
1821 protected void mergeMailingList_Archive( MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1822 {
1823 String src = source.getArchive();
1824 String tgt = target.getArchive();
1825 if ( src != null && ( sourceDominant || tgt == null ) )
1826 {
1827 builder.archive( src );
1828 builder.location( "archive", source.getLocation( "archive" ) );
1829 }
1830 }
1831 protected void mergeMailingList_OtherArchives( MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context )
1832 {
1833 builder.otherArchives( merge( target.getOtherArchives(), source.getOtherArchives(), sourceDominant, e -> e ) );
1834 }
1835
1836 protected Organization mergeOrganization( Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context )
1837 {
1838 Organization.Builder builder = Organization.newBuilder( target );
1839 mergeOrganization( builder, target, source, sourceDominant, context );
1840 return builder.build();
1841 }
1842
1843 protected void mergeOrganization( Organization.Builder builder, Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context )
1844 {
1845 mergeOrganization_Name( builder, target, source, sourceDominant, context );
1846 mergeOrganization_Url( builder, target, source, sourceDominant, context );
1847 }
1848
1849 protected void mergeOrganization_Name( Organization.Builder builder, Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context )
1850 {
1851 String src = source.getName();
1852 String tgt = target.getName();
1853 if ( src != null && ( sourceDominant || tgt == null ) )
1854 {
1855 builder.name( src );
1856 builder.location( "name", source.getLocation( "name" ) );
1857 }
1858 }
1859 protected void mergeOrganization_Url( Organization.Builder builder, Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context )
1860 {
1861 String src = source.getUrl();
1862 String tgt = target.getUrl();
1863 if ( src != null && ( sourceDominant || tgt == null ) )
1864 {
1865 builder.url( src );
1866 builder.location( "url", source.getLocation( "url" ) );
1867 }
1868 }
1869
1870 protected PatternSet mergePatternSet( PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context )
1871 {
1872 PatternSet.Builder builder = PatternSet.newBuilder( target );
1873 mergePatternSet( builder, target, source, sourceDominant, context );
1874 return builder.build();
1875 }
1876
1877 protected void mergePatternSet( PatternSet.Builder builder, PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context )
1878 {
1879 mergePatternSet_Includes( builder, target, source, sourceDominant, context );
1880 mergePatternSet_Excludes( builder, target, source, sourceDominant, context );
1881 }
1882
1883 protected void mergePatternSet_Includes( PatternSet.Builder builder, PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context )
1884 {
1885 builder.includes( merge( target.getIncludes(), source.getIncludes(), sourceDominant, e -> e ) );
1886 }
1887 protected void mergePatternSet_Excludes( PatternSet.Builder builder, PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context )
1888 {
1889 builder.excludes( merge( target.getExcludes(), source.getExcludes(), sourceDominant, e -> e ) );
1890 }
1891
1892 protected Parent mergeParent( Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1893 {
1894 Parent.Builder builder = Parent.newBuilder( target );
1895 mergeParent( builder, target, source, sourceDominant, context );
1896 return builder.build();
1897 }
1898
1899 protected void mergeParent( Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1900 {
1901 mergeParent_GroupId( builder, target, source, sourceDominant, context );
1902 mergeParent_ArtifactId( builder, target, source, sourceDominant, context );
1903 mergeParent_Version( builder, target, source, sourceDominant, context );
1904 mergeParent_RelativePath( builder, target, source, sourceDominant, context );
1905 }
1906
1907 protected void mergeParent_GroupId( Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1908 {
1909 String src = source.getGroupId();
1910 String tgt = target.getGroupId();
1911 if ( src != null && ( sourceDominant || tgt == null ) )
1912 {
1913 builder.groupId( src );
1914 builder.location( "groupId", source.getLocation( "groupId" ) );
1915 }
1916 }
1917 protected void mergeParent_ArtifactId( Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1918 {
1919 String src = source.getArtifactId();
1920 String tgt = target.getArtifactId();
1921 if ( src != null && ( sourceDominant || tgt == null ) )
1922 {
1923 builder.artifactId( src );
1924 builder.location( "artifactId", source.getLocation( "artifactId" ) );
1925 }
1926 }
1927 protected void mergeParent_Version( Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1928 {
1929 String src = source.getVersion();
1930 String tgt = target.getVersion();
1931 if ( src != null && ( sourceDominant || tgt == null ) )
1932 {
1933 builder.version( src );
1934 builder.location( "version", source.getLocation( "version" ) );
1935 }
1936 }
1937 protected void mergeParent_RelativePath( Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context )
1938 {
1939 String src = source.getRelativePath();
1940 String tgt = target.getRelativePath();
1941 if ( src != null && ( sourceDominant || tgt == null ) )
1942 {
1943 builder.relativePath( src );
1944 builder.location( "relativePath", source.getLocation( "relativePath" ) );
1945 }
1946 }
1947
1948 protected Scm mergeScm( Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1949 {
1950 Scm.Builder builder = Scm.newBuilder( target );
1951 mergeScm( builder, target, source, sourceDominant, context );
1952 return builder.build();
1953 }
1954
1955 protected void mergeScm( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1956 {
1957 mergeScm_Connection( builder, target, source, sourceDominant, context );
1958 mergeScm_DeveloperConnection( builder, target, source, sourceDominant, context );
1959 mergeScm_Tag( builder, target, source, sourceDominant, context );
1960 mergeScm_Url( builder, target, source, sourceDominant, context );
1961 mergeScm_ChildScmConnectionInheritAppendPath( builder, target, source, sourceDominant, context );
1962 mergeScm_ChildScmDeveloperConnectionInheritAppendPath( builder, target, source, sourceDominant, context );
1963 mergeScm_ChildScmUrlInheritAppendPath( builder, target, source, sourceDominant, context );
1964 }
1965
1966 protected void mergeScm_Connection( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1967 {
1968 String src = source.getConnection();
1969 String tgt = target.getConnection();
1970 if ( src != null && ( sourceDominant || tgt == null ) )
1971 {
1972 builder.connection( src );
1973 builder.location( "connection", source.getLocation( "connection" ) );
1974 }
1975 }
1976 protected void mergeScm_DeveloperConnection( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1977 {
1978 String src = source.getDeveloperConnection();
1979 String tgt = target.getDeveloperConnection();
1980 if ( src != null && ( sourceDominant || tgt == null ) )
1981 {
1982 builder.developerConnection( src );
1983 builder.location( "developerConnection", source.getLocation( "developerConnection" ) );
1984 }
1985 }
1986 protected void mergeScm_Tag( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1987 {
1988 String src = source.getTag();
1989 String tgt = target.getTag();
1990 if ( src != null && ( sourceDominant || tgt == null ) )
1991 {
1992 builder.tag( src );
1993 builder.location( "tag", source.getLocation( "tag" ) );
1994 }
1995 }
1996 protected void mergeScm_Url( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
1997 {
1998 String src = source.getUrl();
1999 String tgt = target.getUrl();
2000 if ( src != null && ( sourceDominant || tgt == null ) )
2001 {
2002 builder.url( src );
2003 builder.location( "url", source.getLocation( "url" ) );
2004 }
2005 }
2006 protected void mergeScm_ChildScmConnectionInheritAppendPath( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
2007 {
2008 String src = source.getChildScmConnectionInheritAppendPath();
2009 String tgt = target.getChildScmConnectionInheritAppendPath();
2010 if ( src != null && ( sourceDominant || tgt == null ) )
2011 {
2012 builder.childScmConnectionInheritAppendPath( src );
2013 builder.location( "childScmConnectionInheritAppendPath", source.getLocation( "childScmConnectionInheritAppendPath" ) );
2014 }
2015 }
2016 protected void mergeScm_ChildScmDeveloperConnectionInheritAppendPath( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
2017 {
2018 String src = source.getChildScmDeveloperConnectionInheritAppendPath();
2019 String tgt = target.getChildScmDeveloperConnectionInheritAppendPath();
2020 if ( src != null && ( sourceDominant || tgt == null ) )
2021 {
2022 builder.childScmDeveloperConnectionInheritAppendPath( src );
2023 builder.location( "childScmDeveloperConnectionInheritAppendPath", source.getLocation( "childScmDeveloperConnectionInheritAppendPath" ) );
2024 }
2025 }
2026 protected void mergeScm_ChildScmUrlInheritAppendPath( Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context )
2027 {
2028 String src = source.getChildScmUrlInheritAppendPath();
2029 String tgt = target.getChildScmUrlInheritAppendPath();
2030 if ( src != null && ( sourceDominant || tgt == null ) )
2031 {
2032 builder.childScmUrlInheritAppendPath( src );
2033 builder.location( "childScmUrlInheritAppendPath", source.getLocation( "childScmUrlInheritAppendPath" ) );
2034 }
2035 }
2036
2037 protected FileSet mergeFileSet( FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context )
2038 {
2039 FileSet.Builder builder = FileSet.newBuilder( target );
2040 mergeFileSet( builder, target, source, sourceDominant, context );
2041 return builder.build();
2042 }
2043
2044 protected void mergeFileSet( FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context )
2045 {
2046 mergePatternSet( builder, target ,source, sourceDominant, context );
2047 mergeFileSet_Directory( builder, target, source, sourceDominant, context );
2048 }
2049
2050 protected void mergeFileSet_Includes( FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context )
2051 {
2052 builder.includes( merge( target.getIncludes(), source.getIncludes(), sourceDominant, e -> e ) );
2053 }
2054 protected void mergeFileSet_Excludes( FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context )
2055 {
2056 builder.excludes( merge( target.getExcludes(), source.getExcludes(), sourceDominant, e -> e ) );
2057 }
2058 protected void mergeFileSet_Directory( FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context )
2059 {
2060 String src = source.getDirectory();
2061 String tgt = target.getDirectory();
2062 if ( src != null && ( sourceDominant || tgt == null ) )
2063 {
2064 builder.directory( src );
2065 builder.location( "directory", source.getLocation( "directory" ) );
2066 }
2067 }
2068
2069 protected Resource mergeResource( Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2070 {
2071 Resource.Builder builder = Resource.newBuilder( target );
2072 mergeResource( builder, target, source, sourceDominant, context );
2073 return builder.build();
2074 }
2075
2076 protected void mergeResource( Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2077 {
2078 mergeFileSet( builder, target ,source, sourceDominant, context );
2079 mergeResource_TargetPath( builder, target, source, sourceDominant, context );
2080 mergeResource_Filtering( builder, target, source, sourceDominant, context );
2081 mergeResource_MergeId( builder, target, source, sourceDominant, context );
2082 }
2083
2084 protected void mergeResource_Includes( Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2085 {
2086 builder.includes( merge( target.getIncludes(), source.getIncludes(), sourceDominant, e -> e ) );
2087 }
2088 protected void mergeResource_Excludes( Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2089 {
2090 builder.excludes( merge( target.getExcludes(), source.getExcludes(), sourceDominant, e -> e ) );
2091 }
2092 protected void mergeResource_Directory( Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2093 {
2094 String src = source.getDirectory();
2095 String tgt = target.getDirectory();
2096 if ( src != null && ( sourceDominant || tgt == null ) )
2097 {
2098 builder.directory( src );
2099 builder.location( "directory", source.getLocation( "directory" ) );
2100 }
2101 }
2102 protected void mergeResource_TargetPath( Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2103 {
2104 String src = source.getTargetPath();
2105 String tgt = target.getTargetPath();
2106 if ( src != null && ( sourceDominant || tgt == null ) )
2107 {
2108 builder.targetPath( src );
2109 builder.location( "targetPath", source.getLocation( "targetPath" ) );
2110 }
2111 }
2112 protected void mergeResource_Filtering( Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2113 {
2114 String src = source.getFiltering();
2115 String tgt = target.getFiltering();
2116 if ( src != null && ( sourceDominant || tgt == null ) )
2117 {
2118 builder.filtering( src );
2119 builder.location( "filtering", source.getLocation( "filtering" ) );
2120 }
2121 }
2122 protected void mergeResource_MergeId( Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context )
2123 {
2124 String src = source.getMergeId();
2125 String tgt = target.getMergeId();
2126 if ( src != null && ( sourceDominant || tgt == null ) )
2127 {
2128 builder.mergeId( src );
2129 builder.location( "mergeId", source.getLocation( "mergeId" ) );
2130 }
2131 }
2132
2133 protected RepositoryBase mergeRepositoryBase( RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context )
2134 {
2135 RepositoryBase.Builder builder = RepositoryBase.newBuilder( target );
2136 mergeRepositoryBase( builder, target, source, sourceDominant, context );
2137 return builder.build();
2138 }
2139
2140 protected void mergeRepositoryBase( RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context )
2141 {
2142 mergeRepositoryBase_Id( builder, target, source, sourceDominant, context );
2143 mergeRepositoryBase_Name( builder, target, source, sourceDominant, context );
2144 mergeRepositoryBase_Url( builder, target, source, sourceDominant, context );
2145 mergeRepositoryBase_Layout( builder, target, source, sourceDominant, context );
2146 }
2147
2148 protected void mergeRepositoryBase_Id( RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context )
2149 {
2150 String src = source.getId();
2151 String tgt = target.getId();
2152 if ( src != null && ( sourceDominant || tgt == null ) )
2153 {
2154 builder.id( src );
2155 builder.location( "id", source.getLocation( "id" ) );
2156 }
2157 }
2158 protected void mergeRepositoryBase_Name( RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context )
2159 {
2160 String src = source.getName();
2161 String tgt = target.getName();
2162 if ( src != null && ( sourceDominant || tgt == null ) )
2163 {
2164 builder.name( src );
2165 builder.location( "name", source.getLocation( "name" ) );
2166 }
2167 }
2168 protected void mergeRepositoryBase_Url( RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context )
2169 {
2170 String src = source.getUrl();
2171 String tgt = target.getUrl();
2172 if ( src != null && ( sourceDominant || tgt == null ) )
2173 {
2174 builder.url( src );
2175 builder.location( "url", source.getLocation( "url" ) );
2176 }
2177 }
2178 protected void mergeRepositoryBase_Layout( RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context )
2179 {
2180 String src = source.getLayout();
2181 String tgt = target.getLayout();
2182 if ( src != null && ( sourceDominant || tgt == null ) )
2183 {
2184 builder.layout( src );
2185 builder.location( "layout", source.getLocation( "layout" ) );
2186 }
2187 }
2188
2189 protected Repository mergeRepository( Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2190 {
2191 Repository.Builder builder = Repository.newBuilder( target );
2192 mergeRepository( builder, target, source, sourceDominant, context );
2193 return builder.build();
2194 }
2195
2196 protected void mergeRepository( Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2197 {
2198 mergeRepositoryBase( builder, target ,source, sourceDominant, context );
2199 mergeRepository_Releases( builder, target, source, sourceDominant, context );
2200 mergeRepository_Snapshots( builder, target, source, sourceDominant, context );
2201 }
2202
2203 protected void mergeRepository_Id( Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2204 {
2205 String src = source.getId();
2206 String tgt = target.getId();
2207 if ( src != null && ( sourceDominant || tgt == null ) )
2208 {
2209 builder.id( src );
2210 builder.location( "id", source.getLocation( "id" ) );
2211 }
2212 }
2213 protected void mergeRepository_Name( Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2214 {
2215 String src = source.getName();
2216 String tgt = target.getName();
2217 if ( src != null && ( sourceDominant || tgt == null ) )
2218 {
2219 builder.name( src );
2220 builder.location( "name", source.getLocation( "name" ) );
2221 }
2222 }
2223 protected void mergeRepository_Url( Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2224 {
2225 String src = source.getUrl();
2226 String tgt = target.getUrl();
2227 if ( src != null && ( sourceDominant || tgt == null ) )
2228 {
2229 builder.url( src );
2230 builder.location( "url", source.getLocation( "url" ) );
2231 }
2232 }
2233 protected void mergeRepository_Layout( Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2234 {
2235 String src = source.getLayout();
2236 String tgt = target.getLayout();
2237 if ( src != null && ( sourceDominant || tgt == null ) )
2238 {
2239 builder.layout( src );
2240 builder.location( "layout", source.getLocation( "layout" ) );
2241 }
2242 }
2243 protected void mergeRepository_Releases( Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2244 {
2245 RepositoryPolicy src = source.getReleases();
2246 if ( src != null )
2247 {
2248 RepositoryPolicy tgt = target.getReleases();
2249 if ( tgt == null )
2250 {
2251 tgt = RepositoryPolicy.newInstance( false );
2252 }
2253 RepositoryPolicy merged = mergeRepositoryPolicy( tgt, src, sourceDominant, context );
2254 if ( merged == src )
2255 {
2256 builder.releases( merged );
2257 builder.location( "releases", source.getLocation( "releases" ) );
2258 }
2259 else if ( merged != tgt )
2260 {
2261 builder.releases( merged );
2262 builder.location( "releases", InputLocation.merge( target.getLocation( "releases" ), source.getLocation( "releases" ), sourceDominant ) );
2263 }
2264 }
2265 }
2266 protected void mergeRepository_Snapshots( Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context )
2267 {
2268 RepositoryPolicy src = source.getSnapshots();
2269 if ( src != null )
2270 {
2271 RepositoryPolicy tgt = target.getSnapshots();
2272 if ( tgt == null )
2273 {
2274 tgt = RepositoryPolicy.newInstance( false );
2275 }
2276 RepositoryPolicy merged = mergeRepositoryPolicy( tgt, src, sourceDominant, context );
2277 if ( merged == src )
2278 {
2279 builder.snapshots( merged );
2280 builder.location( "snapshots", source.getLocation( "snapshots" ) );
2281 }
2282 else if ( merged != tgt )
2283 {
2284 builder.snapshots( merged );
2285 builder.location( "snapshots", InputLocation.merge( target.getLocation( "snapshots" ), source.getLocation( "snapshots" ), sourceDominant ) );
2286 }
2287 }
2288 }
2289
2290 protected DeploymentRepository mergeDeploymentRepository( DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2291 {
2292 DeploymentRepository.Builder builder = DeploymentRepository.newBuilder( target );
2293 mergeDeploymentRepository( builder, target, source, sourceDominant, context );
2294 return builder.build();
2295 }
2296
2297 protected void mergeDeploymentRepository( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2298 {
2299 mergeRepository( builder, target ,source, sourceDominant, context );
2300 mergeDeploymentRepository_UniqueVersion( builder, target, source, sourceDominant, context );
2301 }
2302
2303 protected void mergeDeploymentRepository_Id( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2304 {
2305 String src = source.getId();
2306 String tgt = target.getId();
2307 if ( src != null && ( sourceDominant || tgt == null ) )
2308 {
2309 builder.id( src );
2310 builder.location( "id", source.getLocation( "id" ) );
2311 }
2312 }
2313 protected void mergeDeploymentRepository_Name( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2314 {
2315 String src = source.getName();
2316 String tgt = target.getName();
2317 if ( src != null && ( sourceDominant || tgt == null ) )
2318 {
2319 builder.name( src );
2320 builder.location( "name", source.getLocation( "name" ) );
2321 }
2322 }
2323 protected void mergeDeploymentRepository_Url( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2324 {
2325 String src = source.getUrl();
2326 String tgt = target.getUrl();
2327 if ( src != null && ( sourceDominant || tgt == null ) )
2328 {
2329 builder.url( src );
2330 builder.location( "url", source.getLocation( "url" ) );
2331 }
2332 }
2333 protected void mergeDeploymentRepository_Layout( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2334 {
2335 String src = source.getLayout();
2336 String tgt = target.getLayout();
2337 if ( src != null && ( sourceDominant || tgt == null ) )
2338 {
2339 builder.layout( src );
2340 builder.location( "layout", source.getLocation( "layout" ) );
2341 }
2342 }
2343 protected void mergeDeploymentRepository_Releases( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2344 {
2345 RepositoryPolicy src = source.getReleases();
2346 if ( src != null )
2347 {
2348 RepositoryPolicy tgt = target.getReleases();
2349 if ( tgt == null )
2350 {
2351 tgt = RepositoryPolicy.newInstance( false );
2352 }
2353 RepositoryPolicy merged = mergeRepositoryPolicy( tgt, src, sourceDominant, context );
2354 if ( merged == src )
2355 {
2356 builder.releases( merged );
2357 builder.location( "releases", source.getLocation( "releases" ) );
2358 }
2359 else if ( merged != tgt )
2360 {
2361 builder.releases( merged );
2362 builder.location( "releases", InputLocation.merge( target.getLocation( "releases" ), source.getLocation( "releases" ), sourceDominant ) );
2363 }
2364 }
2365 }
2366 protected void mergeDeploymentRepository_Snapshots( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2367 {
2368 RepositoryPolicy src = source.getSnapshots();
2369 if ( src != null )
2370 {
2371 RepositoryPolicy tgt = target.getSnapshots();
2372 if ( tgt == null )
2373 {
2374 tgt = RepositoryPolicy.newInstance( false );
2375 }
2376 RepositoryPolicy merged = mergeRepositoryPolicy( tgt, src, sourceDominant, context );
2377 if ( merged == src )
2378 {
2379 builder.snapshots( merged );
2380 builder.location( "snapshots", source.getLocation( "snapshots" ) );
2381 }
2382 else if ( merged != tgt )
2383 {
2384 builder.snapshots( merged );
2385 builder.location( "snapshots", InputLocation.merge( target.getLocation( "snapshots" ), source.getLocation( "snapshots" ), sourceDominant ) );
2386 }
2387 }
2388 }
2389 protected void mergeDeploymentRepository_UniqueVersion( DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context )
2390 {
2391 if ( sourceDominant )
2392 {
2393 builder.uniqueVersion( source.isUniqueVersion() );
2394 }
2395 }
2396
2397 protected RepositoryPolicy mergeRepositoryPolicy( RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context )
2398 {
2399 RepositoryPolicy.Builder builder = RepositoryPolicy.newBuilder( target );
2400 mergeRepositoryPolicy( builder, target, source, sourceDominant, context );
2401 return builder.build();
2402 }
2403
2404 protected void mergeRepositoryPolicy( RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context )
2405 {
2406 mergeRepositoryPolicy_Enabled( builder, target, source, sourceDominant, context );
2407 mergeRepositoryPolicy_UpdatePolicy( builder, target, source, sourceDominant, context );
2408 mergeRepositoryPolicy_ChecksumPolicy( builder, target, source, sourceDominant, context );
2409 }
2410
2411 protected void mergeRepositoryPolicy_Enabled( RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context )
2412 {
2413 String src = source.getEnabled();
2414 String tgt = target.getEnabled();
2415 if ( src != null && ( sourceDominant || tgt == null ) )
2416 {
2417 builder.enabled( src );
2418 builder.location( "enabled", source.getLocation( "enabled" ) );
2419 }
2420 }
2421 protected void mergeRepositoryPolicy_UpdatePolicy( RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context )
2422 {
2423 String src = source.getUpdatePolicy();
2424 String tgt = target.getUpdatePolicy();
2425 if ( src != null && ( sourceDominant || tgt == null ) )
2426 {
2427 builder.updatePolicy( src );
2428 builder.location( "updatePolicy", source.getLocation( "updatePolicy" ) );
2429 }
2430 }
2431 protected void mergeRepositoryPolicy_ChecksumPolicy( RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context )
2432 {
2433 String src = source.getChecksumPolicy();
2434 String tgt = target.getChecksumPolicy();
2435 if ( src != null && ( sourceDominant || tgt == null ) )
2436 {
2437 builder.checksumPolicy( src );
2438 builder.location( "checksumPolicy", source.getLocation( "checksumPolicy" ) );
2439 }
2440 }
2441
2442 protected Site mergeSite( Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
2443 {
2444 Site.Builder builder = Site.newBuilder( target );
2445 mergeSite( builder, target, source, sourceDominant, context );
2446 return builder.build();
2447 }
2448
2449 protected void mergeSite( Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
2450 {
2451 mergeSite_Id( builder, target, source, sourceDominant, context );
2452 mergeSite_Name( builder, target, source, sourceDominant, context );
2453 mergeSite_Url( builder, target, source, sourceDominant, context );
2454 mergeSite_ChildSiteUrlInheritAppendPath( builder, target, source, sourceDominant, context );
2455 }
2456
2457 protected void mergeSite_Id( Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
2458 {
2459 String src = source.getId();
2460 String tgt = target.getId();
2461 if ( src != null && ( sourceDominant || tgt == null ) )
2462 {
2463 builder.id( src );
2464 builder.location( "id", source.getLocation( "id" ) );
2465 }
2466 }
2467 protected void mergeSite_Name( Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
2468 {
2469 String src = source.getName();
2470 String tgt = target.getName();
2471 if ( src != null && ( sourceDominant || tgt == null ) )
2472 {
2473 builder.name( src );
2474 builder.location( "name", source.getLocation( "name" ) );
2475 }
2476 }
2477 protected void mergeSite_Url( Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
2478 {
2479 String src = source.getUrl();
2480 String tgt = target.getUrl();
2481 if ( src != null && ( sourceDominant || tgt == null ) )
2482 {
2483 builder.url( src );
2484 builder.location( "url", source.getLocation( "url" ) );
2485 }
2486 }
2487 protected void mergeSite_ChildSiteUrlInheritAppendPath( Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context )
2488 {
2489 String src = source.getChildSiteUrlInheritAppendPath();
2490 String tgt = target.getChildSiteUrlInheritAppendPath();
2491 if ( src != null && ( sourceDominant || tgt == null ) )
2492 {
2493 builder.childSiteUrlInheritAppendPath( src );
2494 builder.location( "childSiteUrlInheritAppendPath", source.getLocation( "childSiteUrlInheritAppendPath" ) );
2495 }
2496 }
2497
2498 protected ConfigurationContainer mergeConfigurationContainer( ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context )
2499 {
2500 ConfigurationContainer.Builder builder = ConfigurationContainer.newBuilder( target );
2501 mergeConfigurationContainer( builder, target, source, sourceDominant, context );
2502 return builder.build();
2503 }
2504
2505 protected void mergeConfigurationContainer( ConfigurationContainer.Builder builder, ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context )
2506 {
2507 mergeConfigurationContainer_Inherited( builder, target, source, sourceDominant, context );
2508 mergeConfigurationContainer_Configuration( builder, target, source, sourceDominant, context );
2509 }
2510
2511 protected void mergeConfigurationContainer_Inherited( ConfigurationContainer.Builder builder, ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context )
2512 {
2513 String src = source.getInherited();
2514 String tgt = target.getInherited();
2515 if ( src != null && ( sourceDominant || tgt == null ) )
2516 {
2517 builder.inherited( src );
2518 builder.location( "inherited", source.getLocation( "inherited" ) );
2519 }
2520 }
2521 protected void mergeConfigurationContainer_Configuration( ConfigurationContainer.Builder builder, ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context )
2522 {
2523 XmlNode src = source.getConfiguration();
2524 if ( src != null )
2525 {
2526 XmlNode tgt = target.getConfiguration();
2527 if ( tgt == null )
2528 {
2529 builder.configuration( src );
2530 }
2531 else if ( sourceDominant )
2532 {
2533 builder.configuration( src.merge( tgt ) );
2534 }
2535 else
2536 {
2537 builder.configuration( tgt.merge( src ) );
2538 }
2539 }
2540 }
2541
2542 protected Plugin mergePlugin( Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2543 {
2544 Plugin.Builder builder = Plugin.newBuilder( target );
2545 mergePlugin( builder, target, source, sourceDominant, context );
2546 return builder.build();
2547 }
2548
2549 protected void mergePlugin( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2550 {
2551 mergeConfigurationContainer( builder, target ,source, sourceDominant, context );
2552 mergePlugin_GroupId( builder, target, source, sourceDominant, context );
2553 mergePlugin_ArtifactId( builder, target, source, sourceDominant, context );
2554 mergePlugin_Version( builder, target, source, sourceDominant, context );
2555 mergePlugin_Extensions( builder, target, source, sourceDominant, context );
2556 mergePlugin_Executions( builder, target, source, sourceDominant, context );
2557 mergePlugin_Dependencies( builder, target, source, sourceDominant, context );
2558 }
2559
2560 protected void mergePlugin_Inherited( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2561 {
2562 String src = source.getInherited();
2563 String tgt = target.getInherited();
2564 if ( src != null && ( sourceDominant || tgt == null ) )
2565 {
2566 builder.inherited( src );
2567 builder.location( "inherited", source.getLocation( "inherited" ) );
2568 }
2569 }
2570 protected void mergePlugin_Configuration( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2571 {
2572 XmlNode src = source.getConfiguration();
2573 if ( src != null )
2574 {
2575 XmlNode tgt = target.getConfiguration();
2576 if ( tgt == null )
2577 {
2578 builder.configuration( src );
2579 }
2580 else if ( sourceDominant )
2581 {
2582 builder.configuration( src.merge( tgt ) );
2583 }
2584 else
2585 {
2586 builder.configuration( tgt.merge( src ) );
2587 }
2588 }
2589 }
2590 protected void mergePlugin_GroupId( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2591 {
2592 String src = source.getGroupId();
2593 String tgt = target.getGroupId();
2594 if ( src != null && ( sourceDominant || tgt == null ) )
2595 {
2596 builder.groupId( src );
2597 builder.location( "groupId", source.getLocation( "groupId" ) );
2598 }
2599 }
2600 protected void mergePlugin_ArtifactId( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2601 {
2602 String src = source.getArtifactId();
2603 String tgt = target.getArtifactId();
2604 if ( src != null && ( sourceDominant || tgt == null ) )
2605 {
2606 builder.artifactId( src );
2607 builder.location( "artifactId", source.getLocation( "artifactId" ) );
2608 }
2609 }
2610 protected void mergePlugin_Version( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2611 {
2612 String src = source.getVersion();
2613 String tgt = target.getVersion();
2614 if ( src != null && ( sourceDominant || tgt == null ) )
2615 {
2616 builder.version( src );
2617 builder.location( "version", source.getLocation( "version" ) );
2618 }
2619 }
2620 protected void mergePlugin_Extensions( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2621 {
2622 String src = source.getExtensions();
2623 String tgt = target.getExtensions();
2624 if ( src != null && ( sourceDominant || tgt == null ) )
2625 {
2626 builder.extensions( src );
2627 builder.location( "extensions", source.getLocation( "extensions" ) );
2628 }
2629 }
2630 protected void mergePlugin_Executions( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2631 {
2632 if (deepMerge) {
2633 builder.executions( merge( target.getExecutions(), source.getExecutions(), getPluginExecutionKey(),
2634 ( t, s ) -> mergePluginExecution( t, s, sourceDominant, context ) ) );
2635 } else {
2636 builder.executions( merge( target.getExecutions(), source.getExecutions(), sourceDominant, getPluginExecutionKey() ) );
2637 }
2638 }
2639 protected void mergePlugin_Dependencies( Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context )
2640 {
2641 if (deepMerge) {
2642 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), getDependencyKey(),
2643 ( t, s ) -> mergeDependency( t, s, sourceDominant, context ) ) );
2644 } else {
2645 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey() ) );
2646 }
2647 }
2648
2649 protected PluginExecution mergePluginExecution( PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2650 {
2651 PluginExecution.Builder builder = PluginExecution.newBuilder( target );
2652 mergePluginExecution( builder, target, source, sourceDominant, context );
2653 return builder.build();
2654 }
2655
2656 protected void mergePluginExecution( PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2657 {
2658 mergeConfigurationContainer( builder, target ,source, sourceDominant, context );
2659 mergePluginExecution_Id( builder, target, source, sourceDominant, context );
2660 mergePluginExecution_Phase( builder, target, source, sourceDominant, context );
2661 mergePluginExecution_Priority( builder, target, source, sourceDominant, context );
2662 mergePluginExecution_Goals( builder, target, source, sourceDominant, context );
2663 }
2664
2665 protected void mergePluginExecution_Inherited( PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2666 {
2667 String src = source.getInherited();
2668 String tgt = target.getInherited();
2669 if ( src != null && ( sourceDominant || tgt == null ) )
2670 {
2671 builder.inherited( src );
2672 builder.location( "inherited", source.getLocation( "inherited" ) );
2673 }
2674 }
2675 protected void mergePluginExecution_Configuration( PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2676 {
2677 XmlNode src = source.getConfiguration();
2678 if ( src != null )
2679 {
2680 XmlNode tgt = target.getConfiguration();
2681 if ( tgt == null )
2682 {
2683 builder.configuration( src );
2684 }
2685 else if ( sourceDominant )
2686 {
2687 builder.configuration( src.merge( tgt ) );
2688 }
2689 else
2690 {
2691 builder.configuration( tgt.merge( src ) );
2692 }
2693 }
2694 }
2695 protected void mergePluginExecution_Id( PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2696 {
2697 String src = source.getId();
2698 String tgt = target.getId();
2699 if ( src != null && ( sourceDominant || tgt == null ) )
2700 {
2701 builder.id( src );
2702 builder.location( "id", source.getLocation( "id" ) );
2703 }
2704 }
2705 protected void mergePluginExecution_Phase( PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2706 {
2707 String src = source.getPhase();
2708 String tgt = target.getPhase();
2709 if ( src != null && ( sourceDominant || tgt == null ) )
2710 {
2711 builder.phase( src );
2712 builder.location( "phase", source.getLocation( "phase" ) );
2713 }
2714 }
2715 protected void mergePluginExecution_Priority( PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2716 {
2717 if ( sourceDominant )
2718 {
2719 builder.priority( source.getPriority() );
2720 }
2721 }
2722 protected void mergePluginExecution_Goals( PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context )
2723 {
2724 builder.goals( merge( target.getGoals(), source.getGoals(), sourceDominant, e -> e ) );
2725 }
2726
2727 protected DependencyManagement mergeDependencyManagement( DependencyManagement target, DependencyManagement source, boolean sourceDominant, Map<Object, Object> context )
2728 {
2729 DependencyManagement.Builder builder = DependencyManagement.newBuilder( target );
2730 mergeDependencyManagement( builder, target, source, sourceDominant, context );
2731 return builder.build();
2732 }
2733
2734 protected void mergeDependencyManagement( DependencyManagement.Builder builder, DependencyManagement target, DependencyManagement source, boolean sourceDominant, Map<Object, Object> context )
2735 {
2736 mergeDependencyManagement_Dependencies( builder, target, source, sourceDominant, context );
2737 }
2738
2739 protected void mergeDependencyManagement_Dependencies( DependencyManagement.Builder builder, DependencyManagement target, DependencyManagement source, boolean sourceDominant, Map<Object, Object> context )
2740 {
2741 if (deepMerge) {
2742 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), getDependencyKey(),
2743 ( t, s ) -> mergeDependency( t, s, sourceDominant, context ) ) );
2744 } else {
2745 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey() ) );
2746 }
2747 }
2748
2749 protected PluginManagement mergePluginManagement( PluginManagement target, PluginManagement source, boolean sourceDominant, Map<Object, Object> context )
2750 {
2751 PluginManagement.Builder builder = PluginManagement.newBuilder( target );
2752 mergePluginManagement( builder, target, source, sourceDominant, context );
2753 return builder.build();
2754 }
2755
2756 protected void mergePluginManagement( PluginManagement.Builder builder, PluginManagement target, PluginManagement source, boolean sourceDominant, Map<Object, Object> context )
2757 {
2758 mergePluginContainer( builder, target ,source, sourceDominant, context );
2759 }
2760
2761 protected void mergePluginManagement_Plugins( PluginManagement.Builder builder, PluginManagement target, PluginManagement source, boolean sourceDominant, Map<Object, Object> context )
2762 {
2763 if (deepMerge) {
2764 builder.plugins( merge( target.getPlugins(), source.getPlugins(), getPluginKey(),
2765 ( t, s ) -> mergePlugin( t, s, sourceDominant, context ) ) );
2766 } else {
2767 builder.plugins( merge( target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey() ) );
2768 }
2769 }
2770
2771 protected Reporting mergeReporting( Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context )
2772 {
2773 Reporting.Builder builder = Reporting.newBuilder( target );
2774 mergeReporting( builder, target, source, sourceDominant, context );
2775 return builder.build();
2776 }
2777
2778 protected void mergeReporting( Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context )
2779 {
2780 mergeReporting_ExcludeDefaults( builder, target, source, sourceDominant, context );
2781 mergeReporting_OutputDirectory( builder, target, source, sourceDominant, context );
2782 mergeReporting_Plugins( builder, target, source, sourceDominant, context );
2783 }
2784
2785 protected void mergeReporting_ExcludeDefaults( Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context )
2786 {
2787 String src = source.getExcludeDefaults();
2788 String tgt = target.getExcludeDefaults();
2789 if ( src != null && ( sourceDominant || tgt == null ) )
2790 {
2791 builder.excludeDefaults( src );
2792 builder.location( "excludeDefaults", source.getLocation( "excludeDefaults" ) );
2793 }
2794 }
2795 protected void mergeReporting_OutputDirectory( Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context )
2796 {
2797 String src = source.getOutputDirectory();
2798 String tgt = target.getOutputDirectory();
2799 if ( src != null && ( sourceDominant || tgt == null ) )
2800 {
2801 builder.outputDirectory( src );
2802 builder.location( "outputDirectory", source.getLocation( "outputDirectory" ) );
2803 }
2804 }
2805 protected void mergeReporting_Plugins( Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context )
2806 {
2807 if (deepMerge) {
2808 builder.plugins( merge( target.getPlugins(), source.getPlugins(), getReportPluginKey(),
2809 ( t, s ) -> mergeReportPlugin( t, s, sourceDominant, context ) ) );
2810 } else {
2811 builder.plugins( merge( target.getPlugins(), source.getPlugins(), sourceDominant, getReportPluginKey() ) );
2812 }
2813 }
2814
2815 protected Profile mergeProfile( Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2816 {
2817 Profile.Builder builder = Profile.newBuilder( target );
2818 mergeProfile( builder, target, source, sourceDominant, context );
2819 return builder.build();
2820 }
2821
2822 protected void mergeProfile( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2823 {
2824 mergeModelBase( builder, target ,source, sourceDominant, context );
2825 mergeProfile_Id( builder, target, source, sourceDominant, context );
2826 mergeProfile_Activation( builder, target, source, sourceDominant, context );
2827 mergeProfile_Build( builder, target, source, sourceDominant, context );
2828 }
2829
2830 protected void mergeProfile_Modules( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2831 {
2832 builder.modules( merge( target.getModules(), source.getModules(), sourceDominant, e -> e ) );
2833 }
2834 protected void mergeProfile_DistributionManagement( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2835 {
2836 DistributionManagement src = source.getDistributionManagement();
2837 if ( src != null )
2838 {
2839 DistributionManagement tgt = target.getDistributionManagement();
2840 if ( tgt == null )
2841 {
2842 tgt = DistributionManagement.newInstance( false );
2843 }
2844 DistributionManagement merged = mergeDistributionManagement( tgt, src, sourceDominant, context );
2845 if ( merged == src )
2846 {
2847 builder.distributionManagement( merged );
2848 builder.location( "distributionManagement", source.getLocation( "distributionManagement" ) );
2849 }
2850 else if ( merged != tgt )
2851 {
2852 builder.distributionManagement( merged );
2853 builder.location( "distributionManagement", InputLocation.merge( target.getLocation( "distributionManagement" ), source.getLocation( "distributionManagement" ), sourceDominant ) );
2854 }
2855 }
2856 }
2857 protected void mergeProfile_Properties( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2858 {
2859 Map<String, String> src = source.getProperties();
2860 if ( !src.isEmpty() )
2861 {
2862 Map<String, String> tgt = target.getProperties();
2863 if ( tgt.isEmpty() )
2864 {
2865 builder.properties( src );
2866 builder.location( "properties", source.getLocation( "properties" ) );
2867 }
2868 else
2869 {
2870 Map<String, String> merged = new HashMap<>();
2871 merged.putAll( sourceDominant ? target.getProperties() : source.getProperties() );
2872 merged.putAll( sourceDominant ? source.getProperties() : target.getProperties() );
2873 builder.properties( merged );
2874 builder.location( "properties", InputLocation.merge( target.getLocation( "properties" ), source.getLocation( "properties" ), sourceDominant ) );
2875 }
2876 }
2877 }
2878 protected void mergeProfile_DependencyManagement( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2879 {
2880 DependencyManagement src = source.getDependencyManagement();
2881 if ( src != null )
2882 {
2883 DependencyManagement tgt = target.getDependencyManagement();
2884 if ( tgt == null )
2885 {
2886 tgt = DependencyManagement.newInstance( false );
2887 }
2888 DependencyManagement merged = mergeDependencyManagement( tgt, src, sourceDominant, context );
2889 if ( merged == src )
2890 {
2891 builder.dependencyManagement( merged );
2892 builder.location( "dependencyManagement", source.getLocation( "dependencyManagement" ) );
2893 }
2894 else if ( merged != tgt )
2895 {
2896 builder.dependencyManagement( merged );
2897 builder.location( "dependencyManagement", InputLocation.merge( target.getLocation( "dependencyManagement" ), source.getLocation( "dependencyManagement" ), sourceDominant ) );
2898 }
2899 }
2900 }
2901 protected void mergeProfile_Dependencies( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2902 {
2903 if (deepMerge) {
2904 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), getDependencyKey(),
2905 ( t, s ) -> mergeDependency( t, s, sourceDominant, context ) ) );
2906 } else {
2907 builder.dependencies( merge( target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey() ) );
2908 }
2909 }
2910 protected void mergeProfile_Repositories( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2911 {
2912 if (deepMerge) {
2913 builder.repositories( merge( target.getRepositories(), source.getRepositories(), getRepositoryKey(),
2914 ( t, s ) -> mergeRepository( t, s, sourceDominant, context ) ) );
2915 } else {
2916 builder.repositories( merge( target.getRepositories(), source.getRepositories(), sourceDominant, getRepositoryKey() ) );
2917 }
2918 }
2919 protected void mergeProfile_PluginRepositories( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2920 {
2921 if (deepMerge) {
2922 builder.pluginRepositories( merge( target.getPluginRepositories(), source.getPluginRepositories(), getRepositoryKey(),
2923 ( t, s ) -> mergeRepository( t, s, sourceDominant, context ) ) );
2924 } else {
2925 builder.pluginRepositories( merge( target.getPluginRepositories(), source.getPluginRepositories(), sourceDominant, getRepositoryKey() ) );
2926 }
2927 }
2928 protected void mergeProfile_Reporting( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2929 {
2930 Reporting src = source.getReporting();
2931 if ( src != null )
2932 {
2933 Reporting tgt = target.getReporting();
2934 if ( tgt == null )
2935 {
2936 tgt = Reporting.newInstance( false );
2937 }
2938 Reporting merged = mergeReporting( tgt, src, sourceDominant, context );
2939 if ( merged == src )
2940 {
2941 builder.reporting( merged );
2942 builder.location( "reporting", source.getLocation( "reporting" ) );
2943 }
2944 else if ( merged != tgt )
2945 {
2946 builder.reporting( merged );
2947 builder.location( "reporting", InputLocation.merge( target.getLocation( "reporting" ), source.getLocation( "reporting" ), sourceDominant ) );
2948 }
2949 }
2950 }
2951 protected void mergeProfile_Id( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2952 {
2953 String src = source.getId();
2954 String tgt = target.getId();
2955 if ( src != null && ( sourceDominant || tgt == null ) )
2956 {
2957 builder.id( src );
2958 builder.location( "id", source.getLocation( "id" ) );
2959 }
2960 }
2961 protected void mergeProfile_Activation( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2962 {
2963 Activation src = source.getActivation();
2964 if ( src != null )
2965 {
2966 Activation tgt = target.getActivation();
2967 if ( tgt == null )
2968 {
2969 tgt = Activation.newInstance( false );
2970 }
2971 Activation merged = mergeActivation( tgt, src, sourceDominant, context );
2972 if ( merged == src )
2973 {
2974 builder.activation( merged );
2975 builder.location( "activation", source.getLocation( "activation" ) );
2976 }
2977 else if ( merged != tgt )
2978 {
2979 builder.activation( merged );
2980 builder.location( "activation", InputLocation.merge( target.getLocation( "activation" ), source.getLocation( "activation" ), sourceDominant ) );
2981 }
2982 }
2983 }
2984 protected void mergeProfile_Build( Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context )
2985 {
2986 BuildBase src = source.getBuild();
2987 if ( src != null )
2988 {
2989 BuildBase tgt = target.getBuild();
2990 if ( tgt == null )
2991 {
2992 tgt = BuildBase.newInstance( false );
2993 }
2994 BuildBase merged = mergeBuildBase( tgt, src, sourceDominant, context );
2995 if ( merged == src )
2996 {
2997 builder.build( merged );
2998 builder.location( "build", source.getLocation( "build" ) );
2999 }
3000 else if ( merged != tgt )
3001 {
3002 builder.build( merged );
3003 builder.location( "build", InputLocation.merge( target.getLocation( "build" ), source.getLocation( "build" ), sourceDominant ) );
3004 }
3005 }
3006 }
3007
3008 protected Activation mergeActivation( Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context )
3009 {
3010 Activation.Builder builder = Activation.newBuilder( target );
3011 mergeActivation( builder, target, source, sourceDominant, context );
3012 return builder.build();
3013 }
3014
3015 protected void mergeActivation( Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context )
3016 {
3017 mergeActivation_ActiveByDefault( builder, target, source, sourceDominant, context );
3018 mergeActivation_Jdk( builder, target, source, sourceDominant, context );
3019 mergeActivation_Os( builder, target, source, sourceDominant, context );
3020 mergeActivation_Property( builder, target, source, sourceDominant, context );
3021 mergeActivation_File( builder, target, source, sourceDominant, context );
3022 }
3023
3024 protected void mergeActivation_ActiveByDefault( Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context )
3025 {
3026 if ( sourceDominant )
3027 {
3028 builder.activeByDefault( source.isActiveByDefault() );
3029 }
3030 }
3031 protected void mergeActivation_Jdk( Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context )
3032 {
3033 String src = source.getJdk();
3034 String tgt = target.getJdk();
3035 if ( src != null && ( sourceDominant || tgt == null ) )
3036 {
3037 builder.jdk( src );
3038 builder.location( "jdk", source.getLocation( "jdk" ) );
3039 }
3040 }
3041 protected void mergeActivation_Os( Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context )
3042 {
3043 ActivationOS src = source.getOs();
3044 if ( src != null )
3045 {
3046 ActivationOS tgt = target.getOs();
3047 if ( tgt == null )
3048 {
3049 tgt = ActivationOS.newInstance( false );
3050 }
3051 ActivationOS merged = mergeActivationOS( tgt, src, sourceDominant, context );
3052 if ( merged == src )
3053 {
3054 builder.os( merged );
3055 builder.location( "os", source.getLocation( "os" ) );
3056 }
3057 else if ( merged != tgt )
3058 {
3059 builder.os( merged );
3060 builder.location( "os", InputLocation.merge( target.getLocation( "os" ), source.getLocation( "os" ), sourceDominant ) );
3061 }
3062 }
3063 }
3064 protected void mergeActivation_Property( Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context )
3065 {
3066 ActivationProperty src = source.getProperty();
3067 if ( src != null )
3068 {
3069 ActivationProperty tgt = target.getProperty();
3070 if ( tgt == null )
3071 {
3072 tgt = ActivationProperty.newInstance( false );
3073 }
3074 ActivationProperty merged = mergeActivationProperty( tgt, src, sourceDominant, context );
3075 if ( merged == src )
3076 {
3077 builder.property( merged );
3078 builder.location( "property", source.getLocation( "property" ) );
3079 }
3080 else if ( merged != tgt )
3081 {
3082 builder.property( merged );
3083 builder.location( "property", InputLocation.merge( target.getLocation( "property" ), source.getLocation( "property" ), sourceDominant ) );
3084 }
3085 }
3086 }
3087 protected void mergeActivation_File( Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context )
3088 {
3089 ActivationFile src = source.getFile();
3090 if ( src != null )
3091 {
3092 ActivationFile tgt = target.getFile();
3093 if ( tgt == null )
3094 {
3095 tgt = ActivationFile.newInstance( false );
3096 }
3097 ActivationFile merged = mergeActivationFile( tgt, src, sourceDominant, context );
3098 if ( merged == src )
3099 {
3100 builder.file( merged );
3101 builder.location( "file", source.getLocation( "file" ) );
3102 }
3103 else if ( merged != tgt )
3104 {
3105 builder.file( merged );
3106 builder.location( "file", InputLocation.merge( target.getLocation( "file" ), source.getLocation( "file" ), sourceDominant ) );
3107 }
3108 }
3109 }
3110
3111 protected ActivationProperty mergeActivationProperty( ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context )
3112 {
3113 ActivationProperty.Builder builder = ActivationProperty.newBuilder( target );
3114 mergeActivationProperty( builder, target, source, sourceDominant, context );
3115 return builder.build();
3116 }
3117
3118 protected void mergeActivationProperty( ActivationProperty.Builder builder, ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context )
3119 {
3120 mergeActivationProperty_Name( builder, target, source, sourceDominant, context );
3121 mergeActivationProperty_Value( builder, target, source, sourceDominant, context );
3122 }
3123
3124 protected void mergeActivationProperty_Name( ActivationProperty.Builder builder, ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context )
3125 {
3126 String src = source.getName();
3127 String tgt = target.getName();
3128 if ( src != null && ( sourceDominant || tgt == null ) )
3129 {
3130 builder.name( src );
3131 builder.location( "name", source.getLocation( "name" ) );
3132 }
3133 }
3134 protected void mergeActivationProperty_Value( ActivationProperty.Builder builder, ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context )
3135 {
3136 String src = source.getValue();
3137 String tgt = target.getValue();
3138 if ( src != null && ( sourceDominant || tgt == null ) )
3139 {
3140 builder.value( src );
3141 builder.location( "value", source.getLocation( "value" ) );
3142 }
3143 }
3144
3145 protected ActivationOS mergeActivationOS( ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context )
3146 {
3147 ActivationOS.Builder builder = ActivationOS.newBuilder( target );
3148 mergeActivationOS( builder, target, source, sourceDominant, context );
3149 return builder.build();
3150 }
3151
3152 protected void mergeActivationOS( ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context )
3153 {
3154 mergeActivationOS_Name( builder, target, source, sourceDominant, context );
3155 mergeActivationOS_Family( builder, target, source, sourceDominant, context );
3156 mergeActivationOS_Arch( builder, target, source, sourceDominant, context );
3157 mergeActivationOS_Version( builder, target, source, sourceDominant, context );
3158 }
3159
3160 protected void mergeActivationOS_Name( ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context )
3161 {
3162 String src = source.getName();
3163 String tgt = target.getName();
3164 if ( src != null && ( sourceDominant || tgt == null ) )
3165 {
3166 builder.name( src );
3167 builder.location( "name", source.getLocation( "name" ) );
3168 }
3169 }
3170 protected void mergeActivationOS_Family( ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context )
3171 {
3172 String src = source.getFamily();
3173 String tgt = target.getFamily();
3174 if ( src != null && ( sourceDominant || tgt == null ) )
3175 {
3176 builder.family( src );
3177 builder.location( "family", source.getLocation( "family" ) );
3178 }
3179 }
3180 protected void mergeActivationOS_Arch( ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context )
3181 {
3182 String src = source.getArch();
3183 String tgt = target.getArch();
3184 if ( src != null && ( sourceDominant || tgt == null ) )
3185 {
3186 builder.arch( src );
3187 builder.location( "arch", source.getLocation( "arch" ) );
3188 }
3189 }
3190 protected void mergeActivationOS_Version( ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context )
3191 {
3192 String src = source.getVersion();
3193 String tgt = target.getVersion();
3194 if ( src != null && ( sourceDominant || tgt == null ) )
3195 {
3196 builder.version( src );
3197 builder.location( "version", source.getLocation( "version" ) );
3198 }
3199 }
3200
3201 protected ActivationFile mergeActivationFile( ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context )
3202 {
3203 ActivationFile.Builder builder = ActivationFile.newBuilder( target );
3204 mergeActivationFile( builder, target, source, sourceDominant, context );
3205 return builder.build();
3206 }
3207
3208 protected void mergeActivationFile( ActivationFile.Builder builder, ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context )
3209 {
3210 mergeActivationFile_Missing( builder, target, source, sourceDominant, context );
3211 mergeActivationFile_Exists( builder, target, source, sourceDominant, context );
3212 }
3213
3214 protected void mergeActivationFile_Missing( ActivationFile.Builder builder, ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context )
3215 {
3216 String src = source.getMissing();
3217 String tgt = target.getMissing();
3218 if ( src != null && ( sourceDominant || tgt == null ) )
3219 {
3220 builder.missing( src );
3221 builder.location( "missing", source.getLocation( "missing" ) );
3222 }
3223 }
3224 protected void mergeActivationFile_Exists( ActivationFile.Builder builder, ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context )
3225 {
3226 String src = source.getExists();
3227 String tgt = target.getExists();
3228 if ( src != null && ( sourceDominant || tgt == null ) )
3229 {
3230 builder.exists( src );
3231 builder.location( "exists", source.getLocation( "exists" ) );
3232 }
3233 }
3234
3235 protected ReportPlugin mergeReportPlugin( ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3236 {
3237 ReportPlugin.Builder builder = ReportPlugin.newBuilder( target );
3238 mergeReportPlugin( builder, target, source, sourceDominant, context );
3239 return builder.build();
3240 }
3241
3242 protected void mergeReportPlugin( ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3243 {
3244 mergeConfigurationContainer( builder, target ,source, sourceDominant, context );
3245 mergeReportPlugin_GroupId( builder, target, source, sourceDominant, context );
3246 mergeReportPlugin_ArtifactId( builder, target, source, sourceDominant, context );
3247 mergeReportPlugin_Version( builder, target, source, sourceDominant, context );
3248 mergeReportPlugin_ReportSets( builder, target, source, sourceDominant, context );
3249 }
3250
3251 protected void mergeReportPlugin_Inherited( ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3252 {
3253 String src = source.getInherited();
3254 String tgt = target.getInherited();
3255 if ( src != null && ( sourceDominant || tgt == null ) )
3256 {
3257 builder.inherited( src );
3258 builder.location( "inherited", source.getLocation( "inherited" ) );
3259 }
3260 }
3261 protected void mergeReportPlugin_Configuration( ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3262 {
3263 XmlNode src = source.getConfiguration();
3264 if ( src != null )
3265 {
3266 XmlNode tgt = target.getConfiguration();
3267 if ( tgt == null )
3268 {
3269 builder.configuration( src );
3270 }
3271 else if ( sourceDominant )
3272 {
3273 builder.configuration( src.merge( tgt ) );
3274 }
3275 else
3276 {
3277 builder.configuration( tgt.merge( src ) );
3278 }
3279 }
3280 }
3281 protected void mergeReportPlugin_GroupId( ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3282 {
3283 String src = source.getGroupId();
3284 String tgt = target.getGroupId();
3285 if ( src != null && ( sourceDominant || tgt == null ) )
3286 {
3287 builder.groupId( src );
3288 builder.location( "groupId", source.getLocation( "groupId" ) );
3289 }
3290 }
3291 protected void mergeReportPlugin_ArtifactId( ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3292 {
3293 String src = source.getArtifactId();
3294 String tgt = target.getArtifactId();
3295 if ( src != null && ( sourceDominant || tgt == null ) )
3296 {
3297 builder.artifactId( src );
3298 builder.location( "artifactId", source.getLocation( "artifactId" ) );
3299 }
3300 }
3301 protected void mergeReportPlugin_Version( ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3302 {
3303 String src = source.getVersion();
3304 String tgt = target.getVersion();
3305 if ( src != null && ( sourceDominant || tgt == null ) )
3306 {
3307 builder.version( src );
3308 builder.location( "version", source.getLocation( "version" ) );
3309 }
3310 }
3311 protected void mergeReportPlugin_ReportSets( ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context )
3312 {
3313 if (deepMerge) {
3314 builder.reportSets( merge( target.getReportSets(), source.getReportSets(), getReportSetKey(),
3315 ( t, s ) -> mergeReportSet( t, s, sourceDominant, context ) ) );
3316 } else {
3317 builder.reportSets( merge( target.getReportSets(), source.getReportSets(), sourceDominant, getReportSetKey() ) );
3318 }
3319 }
3320
3321 protected ReportSet mergeReportSet( ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context )
3322 {
3323 ReportSet.Builder builder = ReportSet.newBuilder( target );
3324 mergeReportSet( builder, target, source, sourceDominant, context );
3325 return builder.build();
3326 }
3327
3328 protected void mergeReportSet( ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context )
3329 {
3330 mergeConfigurationContainer( builder, target ,source, sourceDominant, context );
3331 mergeReportSet_Id( builder, target, source, sourceDominant, context );
3332 mergeReportSet_Reports( builder, target, source, sourceDominant, context );
3333 }
3334
3335 protected void mergeReportSet_Inherited( ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context )
3336 {
3337 String src = source.getInherited();
3338 String tgt = target.getInherited();
3339 if ( src != null && ( sourceDominant || tgt == null ) )
3340 {
3341 builder.inherited( src );
3342 builder.location( "inherited", source.getLocation( "inherited" ) );
3343 }
3344 }
3345 protected void mergeReportSet_Configuration( ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context )
3346 {
3347 XmlNode src = source.getConfiguration();
3348 if ( src != null )
3349 {
3350 XmlNode tgt = target.getConfiguration();
3351 if ( tgt == null )
3352 {
3353 builder.configuration( src );
3354 }
3355 else if ( sourceDominant )
3356 {
3357 builder.configuration( src.merge( tgt ) );
3358 }
3359 else
3360 {
3361 builder.configuration( tgt.merge( src ) );
3362 }
3363 }
3364 }
3365 protected void mergeReportSet_Id( ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context )
3366 {
3367 String src = source.getId();
3368 String tgt = target.getId();
3369 if ( src != null && ( sourceDominant || tgt == null ) )
3370 {
3371 builder.id( src );
3372 builder.location( "id", source.getLocation( "id" ) );
3373 }
3374 }
3375 protected void mergeReportSet_Reports( ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context )
3376 {
3377 builder.reports( merge( target.getReports(), source.getReports(), sourceDominant, e -> e ) );
3378 }
3379
3380 protected Prerequisites mergePrerequisites( Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context )
3381 {
3382 Prerequisites.Builder builder = Prerequisites.newBuilder( target );
3383 mergePrerequisites( builder, target, source, sourceDominant, context );
3384 return builder.build();
3385 }
3386
3387 protected void mergePrerequisites( Prerequisites.Builder builder, Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context )
3388 {
3389 mergePrerequisites_Maven( builder, target, source, sourceDominant, context );
3390 }
3391
3392 protected void mergePrerequisites_Maven( Prerequisites.Builder builder, Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context )
3393 {
3394 String src = source.getMaven();
3395 String tgt = target.getMaven();
3396 if ( src != null && ( sourceDominant || tgt == null ) )
3397 {
3398 builder.maven( src );
3399 builder.location( "maven", source.getLocation( "maven" ) );
3400 }
3401 }
3402
3403 protected Relocation mergeRelocation( Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context )
3404 {
3405 Relocation.Builder builder = Relocation.newBuilder( target );
3406 mergeRelocation( builder, target, source, sourceDominant, context );
3407 return builder.build();
3408 }
3409
3410 protected void mergeRelocation( Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context )
3411 {
3412 mergeRelocation_GroupId( builder, target, source, sourceDominant, context );
3413 mergeRelocation_ArtifactId( builder, target, source, sourceDominant, context );
3414 mergeRelocation_Version( builder, target, source, sourceDominant, context );
3415 mergeRelocation_Message( builder, target, source, sourceDominant, context );
3416 }
3417
3418 protected void mergeRelocation_GroupId( Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context )
3419 {
3420 String src = source.getGroupId();
3421 String tgt = target.getGroupId();
3422 if ( src != null && ( sourceDominant || tgt == null ) )
3423 {
3424 builder.groupId( src );
3425 builder.location( "groupId", source.getLocation( "groupId" ) );
3426 }
3427 }
3428 protected void mergeRelocation_ArtifactId( Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context )
3429 {
3430 String src = source.getArtifactId();
3431 String tgt = target.getArtifactId();
3432 if ( src != null && ( sourceDominant || tgt == null ) )
3433 {
3434 builder.artifactId( src );
3435 builder.location( "artifactId", source.getLocation( "artifactId" ) );
3436 }
3437 }
3438 protected void mergeRelocation_Version( Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context )
3439 {
3440 String src = source.getVersion();
3441 String tgt = target.getVersion();
3442 if ( src != null && ( sourceDominant || tgt == null ) )
3443 {
3444 builder.version( src );
3445 builder.location( "version", source.getLocation( "version" ) );
3446 }
3447 }
3448 protected void mergeRelocation_Message( Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context )
3449 {
3450 String src = source.getMessage();
3451 String tgt = target.getMessage();
3452 if ( src != null && ( sourceDominant || tgt == null ) )
3453 {
3454 builder.message( src );
3455 builder.location( "message", source.getLocation( "message" ) );
3456 }
3457 }
3458
3459 protected Extension mergeExtension( Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context )
3460 {
3461 Extension.Builder builder = Extension.newBuilder( target );
3462 mergeExtension( builder, target, source, sourceDominant, context );
3463 return builder.build();
3464 }
3465
3466 protected void mergeExtension( Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context )
3467 {
3468 mergeExtension_GroupId( builder, target, source, sourceDominant, context );
3469 mergeExtension_ArtifactId( builder, target, source, sourceDominant, context );
3470 mergeExtension_Version( builder, target, source, sourceDominant, context );
3471 }
3472
3473 protected void mergeExtension_GroupId( Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context )
3474 {
3475 String src = source.getGroupId();
3476 String tgt = target.getGroupId();
3477 if ( src != null && ( sourceDominant || tgt == null ) )
3478 {
3479 builder.groupId( src );
3480 builder.location( "groupId", source.getLocation( "groupId" ) );
3481 }
3482 }
3483 protected void mergeExtension_ArtifactId( Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context )
3484 {
3485 String src = source.getArtifactId();
3486 String tgt = target.getArtifactId();
3487 if ( src != null && ( sourceDominant || tgt == null ) )
3488 {
3489 builder.artifactId( src );
3490 builder.location( "artifactId", source.getLocation( "artifactId" ) );
3491 }
3492 }
3493 protected void mergeExtension_Version( Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context )
3494 {
3495 String src = source.getVersion();
3496 String tgt = target.getVersion();
3497 if ( src != null && ( sourceDominant || tgt == null ) )
3498 {
3499 builder.version( src );
3500 builder.location( "version", source.getLocation( "version" ) );
3501 }
3502 }
3503
3504
3505 protected KeyComputer<Model> getModelKey()
3506 {
3507 return v -> v;
3508 }
3509 protected KeyComputer<ModelBase> getModelBaseKey()
3510 {
3511 return v -> v;
3512 }
3513 protected KeyComputer<PluginContainer> getPluginContainerKey()
3514 {
3515 return v -> v;
3516 }
3517 protected KeyComputer<PluginConfiguration> getPluginConfigurationKey()
3518 {
3519 return v -> v;
3520 }
3521 protected KeyComputer<BuildBase> getBuildBaseKey()
3522 {
3523 return v -> v;
3524 }
3525 protected KeyComputer<Build> getBuildKey()
3526 {
3527 return v -> v;
3528 }
3529 protected KeyComputer<CiManagement> getCiManagementKey()
3530 {
3531 return v -> v;
3532 }
3533 protected KeyComputer<Notifier> getNotifierKey()
3534 {
3535 return v -> v;
3536 }
3537 protected KeyComputer<Contributor> getContributorKey()
3538 {
3539 return v -> v;
3540 }
3541 protected KeyComputer<Dependency> getDependencyKey()
3542 {
3543 return v -> v;
3544 }
3545 protected KeyComputer<Developer> getDeveloperKey()
3546 {
3547 return v -> v;
3548 }
3549 protected KeyComputer<Exclusion> getExclusionKey()
3550 {
3551 return v -> v;
3552 }
3553 protected KeyComputer<IssueManagement> getIssueManagementKey()
3554 {
3555 return v -> v;
3556 }
3557 protected KeyComputer<DistributionManagement> getDistributionManagementKey()
3558 {
3559 return v -> v;
3560 }
3561 protected KeyComputer<License> getLicenseKey()
3562 {
3563 return v -> v;
3564 }
3565 protected KeyComputer<MailingList> getMailingListKey()
3566 {
3567 return v -> v;
3568 }
3569 protected KeyComputer<Organization> getOrganizationKey()
3570 {
3571 return v -> v;
3572 }
3573 protected KeyComputer<PatternSet> getPatternSetKey()
3574 {
3575 return v -> v;
3576 }
3577 protected KeyComputer<Parent> getParentKey()
3578 {
3579 return v -> v;
3580 }
3581 protected KeyComputer<Scm> getScmKey()
3582 {
3583 return v -> v;
3584 }
3585 protected KeyComputer<FileSet> getFileSetKey()
3586 {
3587 return v -> v;
3588 }
3589 protected KeyComputer<Resource> getResourceKey()
3590 {
3591 return v -> v;
3592 }
3593 protected KeyComputer<RepositoryBase> getRepositoryBaseKey()
3594 {
3595 return v -> v;
3596 }
3597 protected KeyComputer<Repository> getRepositoryKey()
3598 {
3599 return v -> v;
3600 }
3601 protected KeyComputer<DeploymentRepository> getDeploymentRepositoryKey()
3602 {
3603 return v -> v;
3604 }
3605 protected KeyComputer<RepositoryPolicy> getRepositoryPolicyKey()
3606 {
3607 return v -> v;
3608 }
3609 protected KeyComputer<Site> getSiteKey()
3610 {
3611 return v -> v;
3612 }
3613 protected KeyComputer<ConfigurationContainer> getConfigurationContainerKey()
3614 {
3615 return v -> v;
3616 }
3617 protected KeyComputer<Plugin> getPluginKey()
3618 {
3619 return v -> v;
3620 }
3621 protected KeyComputer<PluginExecution> getPluginExecutionKey()
3622 {
3623 return v -> v;
3624 }
3625 protected KeyComputer<DependencyManagement> getDependencyManagementKey()
3626 {
3627 return v -> v;
3628 }
3629 protected KeyComputer<PluginManagement> getPluginManagementKey()
3630 {
3631 return v -> v;
3632 }
3633 protected KeyComputer<Reporting> getReportingKey()
3634 {
3635 return v -> v;
3636 }
3637 protected KeyComputer<Profile> getProfileKey()
3638 {
3639 return v -> v;
3640 }
3641 protected KeyComputer<Activation> getActivationKey()
3642 {
3643 return v -> v;
3644 }
3645 protected KeyComputer<ActivationProperty> getActivationPropertyKey()
3646 {
3647 return v -> v;
3648 }
3649 protected KeyComputer<ActivationOS> getActivationOSKey()
3650 {
3651 return v -> v;
3652 }
3653 protected KeyComputer<ActivationFile> getActivationFileKey()
3654 {
3655 return v -> v;
3656 }
3657 protected KeyComputer<ReportPlugin> getReportPluginKey()
3658 {
3659 return v -> v;
3660 }
3661 protected KeyComputer<ReportSet> getReportSetKey()
3662 {
3663 return v -> v;
3664 }
3665 protected KeyComputer<Prerequisites> getPrerequisitesKey()
3666 {
3667 return v -> v;
3668 }
3669 protected KeyComputer<Relocation> getRelocationKey()
3670 {
3671 return v -> v;
3672 }
3673 protected KeyComputer<Extension> getExtensionKey()
3674 {
3675 return v -> v;
3676 }
3677
3678
3679
3680
3681
3682 @FunctionalInterface
3683 public interface KeyComputer<T> extends Function<T, Object>
3684 {
3685 }
3686
3687
3688
3689
3690 public static <T> List<T> merge( List<T> tgt, List<T> src, boolean sourceDominant, KeyComputer<T> computer )
3691 {
3692 return merge( tgt, src, computer, ( t, s ) -> sourceDominant ? s : t );
3693 }
3694
3695 public static <T> List<T> merge( List<T> tgt, List<T> src, KeyComputer<T> computer, BinaryOperator<T> remapping )
3696 {
3697 if ( src.isEmpty() )
3698 {
3699 return tgt;
3700 }
3701
3702 MergingList<T> list;
3703 if ( tgt instanceof MergingList )
3704 {
3705 list = (MergingList<T>) tgt;
3706 }
3707 else
3708 {
3709 list = new MergingList<>( computer, src.size() + tgt.size() );
3710 list.mergeAll( tgt, ( t, s ) -> s );
3711 }
3712
3713 list.mergeAll( src, remapping );
3714 return list;
3715 }
3716
3717
3718
3719
3720
3721 private static class MergingList<V> extends AbstractList<V> implements java.io.Serializable
3722 {
3723
3724 private final KeyComputer<V> keyComputer;
3725 private Map<Object, V> map;
3726 private List<V> list;
3727
3728 MergingList( KeyComputer<V> keyComputer, int initialCapacity )
3729 {
3730 this.map = new LinkedHashMap<>( initialCapacity );
3731 this.keyComputer = keyComputer;
3732 }
3733
3734 Object writeReplace() throws ObjectStreamException
3735 {
3736 return new ArrayList<>( this );
3737 }
3738
3739 @Override
3740 public Iterator<V> iterator()
3741 {
3742 if ( map != null )
3743 {
3744 return map.values().iterator();
3745 }
3746 else
3747 {
3748 return list.iterator();
3749 }
3750 }
3751
3752 void mergeAll( Collection<V> vs, BinaryOperator<V> remapping )
3753 {
3754 if ( map == null )
3755 {
3756 map = list.stream().collect( Collectors.toMap( keyComputer,
3757 Function.identity(),
3758 null,
3759 LinkedHashMap::new ) );
3760
3761 list = null;
3762 }
3763
3764 if ( vs instanceof MergingList && ( (MergingList<V>) vs ).map != null )
3765 {
3766 for ( Map.Entry<Object, V> e : ( (MergingList<V>) vs ).map.entrySet() )
3767 {
3768 Object key = e.getKey();
3769 V v = e.getValue();
3770 map.merge( key, v, remapping );
3771 }
3772 }
3773 else
3774 {
3775 for ( V v : vs )
3776 {
3777 Object key = keyComputer.apply( v );
3778
3779 map.merge( key, v, remapping );
3780 }
3781 }
3782 }
3783
3784 @Override
3785 public boolean contains( Object o )
3786 {
3787 if ( map != null )
3788 {
3789 return map.containsValue( o );
3790 }
3791 else
3792 {
3793 return list.contains( o );
3794 }
3795 }
3796
3797 private List<V> asList()
3798 {
3799 if ( list == null )
3800 {
3801 list = new ArrayList<>( map.values() );
3802 map = null;
3803 }
3804 return list;
3805 }
3806
3807 @Override
3808 public void add( int index, V element )
3809 {
3810 asList().add( index, element );
3811 }
3812
3813 @Override
3814 public V remove( int index )
3815 {
3816 return asList().remove( index );
3817 }
3818
3819 @Override
3820 public V get( int index )
3821 {
3822 return asList().get( index );
3823 }
3824
3825 @Override
3826 public int size()
3827 {
3828 if ( map != null )
3829 {
3830 return map.size();
3831 }
3832 else
3833 {
3834 return list.size();
3835 }
3836 }
3837 }
3838 }