You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 325ce47
Browse filesBrowse the repository at this point in the historyBrowse files
feat(android): name the opt-in android.pluginBuildLocation
`pluginBuildLocation: "platforms"` builds plugins in platforms/android/.ns-plugins
and never writes into node_modules; "node_modules" (the default) keeps the
current behaviour and stays as the way back once "platforms" becomes the
default. Any other value fails prepare. The plugin build receives
-Pnativescript.pluginBuildLocation=platforms.
Copy file name to clipboardExpand all lines: gradle-api/README.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ In that build, **only the `dependencies {}` and `repositories {}` blocks of your
76
76
run**: the CLI copies them out of the file. Nothing else in the file runs there, including the
77
77
`apply plugin:` line.
78
78
79
-
On CLI 9.2+ with `android.readOnlyNodeModules` enabled, the CLI loads your `buildscript.gradle` in
79
+
On CLI 9.2+ with `android.pluginBuildLocation: "platforms"`, the CLI loads your `buildscript.gradle` in
80
80
that build and applies the library for you. On older CLIs it doesn't, so the library isn't
81
81
available there. Inside those two blocks, look the extension up instead of assuming it exists, and
82
82
keep the old code as the fallback:
@@ -180,7 +180,7 @@ repositories {
180
180
181
181
## Compatibility
182
182
183
-
|| CLI 9.1 and older | CLI 9.2+ | CLI 9.2+ with `readOnlyNodeModules`|
183
+
|| CLI 9.1 and older | CLI 9.2+ | CLI 9.2+ with `pluginBuildLocation: "platforms"`|
184
184
|---|---|---|---|
185
185
| Plugin not using the library | Unchanged | Unchanged | Gradle reads its files from a copy in `platforms/android/.ns-plugins/`, and its own `buildscript.gradle` also runs in its own `.aar` build |
186
186
| Plugin using the library, app build | Fallback rules | Facts from the CLI | Facts from the CLI |
@@ -194,22 +194,27 @@ Building `platforms/android` from Android Studio works too: CLI 9.2+ leaves the
194
194
after `ns prepare android`, so the library has the same answers without the CLI's command-line
195
195
flags.
196
196
197
-
### For app developers: keeping `node_modules` read-only (opt-in)
197
+
### For app developers: building plugins in `platforms/android` (opt-in)
198
198
199
199
```ts
200
200
// nativescript.config.ts
201
201
exportdefault {
202
-
android: { readOnlyNodeModules: true },
202
+
android: { pluginBuildLocation: "platforms" },
203
203
} satisfiesNativeScriptConfig;
204
204
```
205
205
206
-
With this, the CLI never writes into `node_modules`. It copies each native plugin's
206
+
`android.pluginBuildLocation` sets where the CLI builds plugins' native Android code. The default,
207
+
`"node_modules"`, builds each plugin's `.aar` inside its package, as CLIs up to 9.1 do. With
208
+
`"platforms"`, the CLI never writes into `node_modules`. It copies each native plugin's
207
209
`platforms/android` and `package.json` into `platforms/android/.ns-plugins/<name>/`, builds plugin
208
210
`.aar`s there, and points the Android build at the copies. No runtime change is needed (checked
209
211
against the runtime's Gradle templates from 6.5.3 to current), and Android Studio builds use the
210
212
copies too. Earlier builds may have left `.aar` files inside `node_modules`;
211
213
reinstall `node_modules` once after turning this on to get rid of them.
212
214
215
+
`"platforms"` is opt-in while plugins adopt this library, and is expected to become the default in a
216
+
future major version of the CLI.
217
+
213
218
## Rules for plugin authors
214
219
215
220
- Pin the lowest library version you need; no ranges.
Copy file name to clipboardExpand all lines: gradle-api/schema/nativescript-gradle.schema.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@
78
78
"$ref": "#/$defs/path"
79
79
},
80
80
"nativeDir": {
81
-
"description": "The directory Gradle reads the plugin's Android files from: the package's platforms/android, or the CLI's copy of it when node_modules is kept read-only.",
81
+
"description": "The directory Gradle reads the plugin's Android files from: the package's platforms/android, or the CLI's copy of it in platforms/android/.ns-plugins when the app sets android.pluginBuildLocation to \"platforms\".",
0 commit comments