Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(android): rework merging of external library's resources #11094

Merged
merged 5 commits into from
Oct 30, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion android/cli/lib/base-builder.js
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.
xml.forEachElement(node, function (nodeChild) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
xml.forEachElement(node, function (nodeChild) {
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') === nodeChild.getAttribute('name')) {
alreadyAddedChild.parentNode.removeChild(alreadyAddedChild);
}
});
nodes[node.tagName][n].appendChild(nodeChild.cloneNode(true));
});
_t.logger.warn(__('Merging XML node %s in file %s', String(n).cyan, dest.cyan));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been bothering me for ages, but i think this should be debug rather than warn. Also move it back to the top before doing the actual merging otherwise it could cause confusion when something goes wrong during the merge and the last log was for a completely different merge operation.

return;
}
nodes[node.tagName][n] = node;
}
Expand Down