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