Skip to content

feat(android): per-plugin build options, with aarSuffix to break name clashes - #6132

Open
farfromrefug wants to merge 1 commit into
NativeScript:mainfrom
Akylas:feat/plugin-build-options
Open

feat(android): per-plugin build options, with aarSuffix to break name clashes#6132
farfromrefug wants to merge 1 commit into
NativeScript:mainfrom
Akylas:feat/plugin-build-options

Conversation

@farfromrefug

@farfromrefug farfromrefug commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

The problem

getShortPluginName drops the npm scope:

sanitizePluginName(pluginName).replace(/[\-]/g, "_")  // "@foo/plugin-x" -> "plugin_x"

That name becomes the temp build directory, the produced .aar and the android namespace fallback. Two plugins from different scopes with the same package name — @foo/plugin-x and @bar/plugin-x — both build a plugin_x.aar, and which one gradle ends up linking depends on build order.

What

A project can give one of them a suffix:

// nativescript.config.ts
export default {
  android: {
    plugins: {
      "@bar/plugin-x": { aarSuffix: "-bar" },
    },
  },
} satisfies NativeScriptConfig;

@bar/plugin-x now builds plugin_x_bar.aar and stops colliding.

android.plugins is a map keyed by npm package name whose entries are spread into the options buildAar receives, so it is also where future per-plugin build settings can go. aarSuffix is 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.

setupGradle used to recompute getShortPluginName(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 .aar and 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 build does 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 on IPluginBuildOptions, so a hook can still set it there.

Tests

npm test — 1858 passing. The childProcess stub in test/services/android-plugin-build-service.ts now derives the built .aar name from the plugin directory gradle was pointed at instead of assuming it, which let me add two cases: the default name, and the name with aarSuffix applied.

Notes

From https://github.com/Akylas/nativescript-cli. Independent of #6129, #6130 and #6131, though #6129 also touches IAndroidBuildOptions.gradleArgs and the options object in android-project-service — expect a small textual conflict depending on merge order.

Summary by CodeRabbit

  • New Features

    • Added optional Android plugin configuration for customizing generated .aar filenames with a suffix.
    • Supports per-plugin suffixes to prevent naming conflicts between similarly named plugins.
  • Bug Fixes

    • Improved Android plugin build output naming to consistently honor configured suffixes and plugin paths.

… 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>
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d67eb031-3ab4-461f-9094-3c1d4f87aa40

📥 Commits

Reviewing files that changed from the base of the PR and between 2f9f2e0 and bc7375b.

📒 Files selected for processing (5)
  • lib/definitions/android-plugin-migrator.d.ts
  • lib/definitions/project.d.ts
  • lib/services/android-plugin-build-service.ts
  • lib/services/android-project-service.ts
  • test/services/android-plugin-build-service.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Android 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.

Changes

Android AAR naming

Layer / File(s) Summary
Android plugin configuration contracts
lib/definitions/android-plugin-migrator.d.ts, lib/definitions/project.d.ts
The public types define optional aarSuffix values for Android build options and per-plugin project configuration.
AAR naming and Gradle wiring
lib/services/android-project-service.ts, lib/services/android-plugin-build-service.ts
Per-plugin Android configuration is merged into build options. AAR naming includes the suffix before shortening, and the computed name is passed to Gradle setup.
AAR naming test coverage
test/services/android-plugin-build-service.ts
Tests track the Gradle project directory and verify default and suffix-based AAR filenames.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to bc737

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
Loading

Suggested reviewers: nathanwalker

Poem

A rabbit hops through Gradle’s lane,
With suffixes neat in AAR names.
Short names now stay clear and bright,
Tests guard each build from left to right.
Squeak—no plugin wears the same!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: per-plugin Android build options and the aarSuffix option to prevent AAR name collisions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant