Repository navigation
fix(android): give plugins with clashing short names unique aar names - #6217
edusperoni wants to merge 1 commit into
Conversation
The CLI names a plugin's aar, its temp build project and the `org.nativescript.<name>` namespace fallback after the plugin's short name, which drops the npm scope. Two scoped plugins with the same name, such as `@foo/plugin-x` and `@bar/plugin-x`, therefore both build `plugin_x.aar`, share `platforms/tempPlugin/plugin_x` and get the same fallback namespace. Which plugin's code ends up linked depends on the order they are built in. Each native Android plugin now gets an aar name that is unique in the project. A plugin whose short name no other native plugin shares keeps it, so projects without a clash build exactly as before: same dependencies.json, same aar names and paths. Within a group of plugins that share a short name, scoped plugins get `<scope>_<short>` (the scope without `@`, with characters other than [A-Za-z0-9_] replaced by `_`), an unscoped plugin keeps its short name, and a name that would start with a digit gets a leading `_`. The result does not depend on the order of the dependencies. If two plugins still end up with the same name, prepare fails and names both packages. `ns plugin build` is unchanged. Old Gradle templates add every *.aar in a plugin's platforms/android to the app, so an aar the CLI built under the plugin's previous name would add duplicate classes. When the CLI builds a plugin (it has a manifest or Android sources), each aar in its platforms/android named after another of its candidate names is handled as follows: - the plain short name: earlier CLIs always copied the built aar to `<short>.aar`, overwriting anything the package shipped under that name, so the file is a leftover and is deleted; - the scope-qualified name: only this CLI builds it, so the file is a leftover only when `<tempPlugin>/<name>/build.gradle` sets `project.ext.PLUGIN_NAME` to this plugin's npm name and the temp project has a build output at `<tempPlugin>/<name>/build/outputs/aar/<name>-release.aar`. If the file is byte-identical to that output it is deleted; if it differs, prepare fails with both paths and asks to delete it or run `ns clean`. Otherwise the package ships it and it is left alone. Aars of plugins the CLI does not build are never deleted or flagged. The Android project service reports a plugin for reprepare while its aar is missing under the new name or a leftover is still there, so upgrading the CLI on a project with a clash rebuilds the renamed aars and deletes the old `<short>.aar` in each clashing plugin.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
PR Checklist
What is the current behavior?
The CLI names a plugin's built
.aar, its temporary build project (platforms/tempPlugin/<name>) and theorg.nativescript.<name>namespace fallback after the plugin's short name, which drops the npm scope. Two plugins such as@foo/plugin-xand@bar/plugin-xtherefore both buildplugin_x.aar, share one temp build folder and get the same fallback namespace. Which plugin's code ends up in the app depends on build order. (#6132 proposed anaarSuffixoption to work around it.)What is the new behavior?
Each native Android plugin gets an
.aarname that is unique in the project, with no option needed.dependencies.json, same.aarnames and paths (asserted in tests).<scope>_<short>(e.g.foo_plugin_x); an unscoped plugin keeps the short name; a name starting with a digit gets a leading_. The result doesn't depend on dependency order. If two plugins still end up with the same name (e.g.@foo/plugin-xand@foo/plugin_x), prepare fails and names both packages.*.aarin a plugin'splatforms/androidto the app, so a file built under the previous name would add duplicate classes. Only for plugins the CLI builds (they have a manifest or Android sources):<short>.aaris always a leftover: earlier CLIs copied every build there, overwriting anything the package shipped under that name. It's deleted.<scope>_<short>.aaris a leftover only if its temp build project was built for this plugin (itsbuild.gradlenames it) and has that output: identical → deleted; different → prepare stops with both paths and "delete it or runns clean". Otherwise the package ships it and it's kept..aars once and removes the old<short>.aarfrom each clashing plugin, with no manual step.ns plugin buildis unchanged. Split out of #6175, which builds on it (the facts file there records each plugin's.aarname).Summary by CodeRabbit
New Features
Bug Fixes