Skip to content

Commit

Permalink
build(android): rework merging of external library's resources (#11094)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27252
  • Loading branch information
ypbnv authored and sgtcoolguy committed Oct 30, 2019
1 parent 1bd852b commit 616b749
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion android/cli/lib/base-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,20 @@ AndroidBaseBuilder.prototype.writeXmlFile = function writeXmlFile(srcOrDoc, dest
if (n) {
nodes[node.tagName] || (nodes[node.tagName] = {});
if (nodes[node.tagName][n] && n !== 'app_name') {
_t.logger.warn(__('Overwriting XML node %s in file %s', String(n).cyan, dest.cyan));
// We have a node with the same name. Merging as follows:
// Nodes with the same name get overwritten to maintain backwards compatiblity.
// Nodes with different name are appended to the parent node.
_t.logger.debug(__('Merging XML node %s in file %s', String(n).cyan, dest.cyan));
xml.forEachElement(node, function (childNode) {
// We have node with the same name, remove the current one.
xml.forEachElement(nodes[node.tagName][n], function (alreadyAddedChild) {
if (alreadyAddedChild.getAttribute('name') === childNode.getAttribute('name')) {
alreadyAddedChild.parentNode.removeChild(alreadyAddedChild);
}
});
nodes[node.tagName][n].appendChild(childNode.cloneNode(true));
});
return;
}
nodes[node.tagName][n] = node;
}
Expand Down

0 comments on commit 616b749

Please sign in to comment.