Xml merging utility. For each node in custom xml searches existing path in original xml. If full node path exists, but with different value then value simply overridden. If path is partially exists, then required nodes will be added. Generally its a merge process in most common sense.
Current downside is semantic isn't tracked. For example, if pom contains developer definition and user closure also contains developer then values of existing developer would be simply overridden and not updated tags will remain (for example, id, name email were in pom and closure sets only name and email.. id will remain in merged pom, which is ofc not correct. Assuming pretty similar merge situations to happen.
In order to prevent same path blocks override (e.g. multiple developers), each node in user closure has assigned unique id. When existing node in original tree gets updated, then child node id assigned to original node. Other nodes with the same path will not reuse the same tag because of assigned id.
In cases when tag name in pom closure clash with gradle project method name, '_' prefix could be used. For example, 'relativePath' can't be used as method with the same name present in project, so use '_relativePath' instead.
| Type Params | Return Type | Name and description |
|---|---|---|
|
static void |
mergePom(groovy.util.Node pomXml, groovy.lang.Closure userPom)Complex merge logic is required to avoid tag duplicates. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Complex merge logic is required to avoid tag duplicates. For example, if scm.url tag specified manually and in pom closure then after using simply '+' to append closure scm section will be duplicated. Correct behaviour is to override existing value and reuse section for other sub nodes.
pomXml - pom xmluserPom - user pom closure