feat(android): per-plugin build options, with aarSuffix to break name clashes - #6132
feat(android): per-plugin build options, with aarSuffix to break name clashes#6132farfromrefug wants to merge 1 commit into
Conversation
… clashes
The name of the `.aar` built for a plugin comes from `getShortPluginName`,
which drops the npm scope. `@foo/plugin-x` and `@bar/plugin-x` therefore
both build a `plugin_x.aar` into their own platforms folder, and the one
that gradle picks up depends on which was built last.
A project can now give one of them a suffix:
```js
export default {
android: {
plugins: {
"@bar/plugin-x": { aarSuffix: "-bar" },
},
},
} satisfies NativeScriptConfig;
```
`android.plugins` is a map keyed by npm package name, spread into the
options `buildAar` receives, so it is the place to put future per-plugin
build settings too. The suffix is appended to the plugin name before it is
shortened, and the resulting name is used consistently - for the temp
build directory, the produced `.aar` and the namespace fallback, which
`setupGradle` used to recompute without it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAndroid plugin configuration now supports optional AAR suffixes. The project service passes per-plugin settings into the build service. AAR naming and Gradle setup use the suffix-aware shortened name. Tests cover default and suffixed output names. ChangesAndroid AAR naming
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The PR adds optional per-plugin AAR suffixing while preserving default behavior; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant AndroidProjectService
participant AndroidPluginBuildService
participant Gradle
AndroidProjectService->>AndroidPluginBuildService: pass per-plugin aarSuffix
AndroidPluginBuildService->>AndroidPluginBuildService: derive shortened plugin name
AndroidPluginBuildService->>Gradle: configure project with shortened name
Gradle-->>AndroidPluginBuildService: create release AAR
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The problem
getShortPluginNamedrops the npm scope:That name becomes the temp build directory, the produced
.aarand the android namespace fallback. Two plugins from different scopes with the same package name —@foo/plugin-xand@bar/plugin-x— both build aplugin_x.aar, and which one gradle ends up linking depends on build order.What
A project can give one of them a suffix:
@bar/plugin-xnow buildsplugin_x_bar.aarand stops colliding.android.pluginsis a map keyed by npm package name whose entries are spread into the optionsbuildAarreceives, so it is also where future per-plugin build settings can go.aarSuffixis the only key it carries today.Details
The suffix is appended to the plugin name before it is shortened, so it goes through the same sanitizing as the rest of the name.
setupGradleused to recomputegetShortPluginName(pluginName)for the namespace fallback (org.nativescript.<short name>), which would have kept colliding. It now takes the already-computed name as a parameter, so the temp directory, the.aarand the namespace all agree.Nothing changes for a project that does not set
plugins— the suffix defaults to empty and the name is exactly what it was.Not covered
ns plugin builddoes not read the config: it runs inside a plugin's own directory, where there is no consuming app to declare a suffix. The option is onIPluginBuildOptions, so a hook can still set it there.Tests
npm test— 1858 passing. ThechildProcessstub intest/services/android-plugin-build-service.tsnow derives the built.aarname from the plugin directory gradle was pointed at instead of assuming it, which let me add two cases: the default name, and the name withaarSuffixapplied.Notes
From https://github.com/Akylas/nativescript-cli. Independent of #6129, #6130 and #6131, though #6129 also touches
IAndroidBuildOptions.gradleArgsand the options object inandroid-project-service— expect a small textual conflict depending on merge order.Summary by CodeRabbit
New Features
.aarfilenames with a suffix.Bug Fixes