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