From 2cae53755b1cea6fa3b47e4d3e0ed45bdf6f50bb Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Mon, 23 Nov 2026 16:23:54 -0300 Subject: [PATCH 1/2] feat(android): compile against @nativescript/core through org.nativescript:gradle-api The plugin's own aar build finds core's Android libraries with the nativescript extension when the CLI provides it, instead of building a path into node_modules. On CLIs that don't load the library in that build, the existing tempBuild code runs unchanged. --- .../platforms/android/buildscript.gradle | 6 ++++++ .../platforms/android/include.gradle | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 packages/gesturehandler/platforms/android/buildscript.gradle diff --git a/packages/gesturehandler/platforms/android/buildscript.gradle b/packages/gesturehandler/platforms/android/buildscript.gradle new file mode 100644 index 0000000..62ef1e8 --- /dev/null +++ b/packages/gesturehandler/platforms/android/buildscript.gradle @@ -0,0 +1,6 @@ +repositories { + mavenCentral() +} +dependencies { + classpath "org.nativescript:gradle-api:0.1.0-alpha.1" +} diff --git a/packages/gesturehandler/platforms/android/include.gradle b/packages/gesturehandler/platforms/android/include.gradle index 2ff6bb2..217ebac 100644 --- a/packages/gesturehandler/platforms/android/include.gradle +++ b/packages/gesturehandler/platforms/android/include.gradle @@ -1,9 +1,18 @@ import groovy.json.JsonSlurper +apply plugin: "org.nativescript.api" + dependencies { implementation "androidx.annotation:annotation:1.1.0" - if (project.hasProperty("tempBuild")) { + // In this plugin's own aar build the CLI runs only this block and the next one, and loads + // org.nativescript:gradle-api there only on CLIs that support it, so look the extension up + // instead of assuming it and keep the older code as the fallback. + def ns = project.extensions.findByName("nativescript") + def core = (ns != null && ns.pluginBuild) ? (ns.findPlugin("@nativescript/core") ?: ns.findPlugin("@akylas/nativescript")) : null + if (core != null) { + compileOnly core.artifacts + } else if (project.hasProperty("tempBuild")) { // we need to copy the code in both places as N main gradle system does not support top level code // for now we support only @nativescript/core and @akylas/nativescript // we should have a more generic way @@ -26,7 +35,9 @@ dependencies { } } repositories { - if (project.hasProperty("tempBuild")) { + def ns = project.extensions.findByName("nativescript") + def core = (ns != null && ns.pluginBuild) ? (ns.findPlugin("@nativescript/core") ?: ns.findPlugin("@akylas/nativescript")) : null + if (core == null && project.hasProperty("tempBuild")) { // we need to copy the code in both places as N main gradle system does not support top level code // for now we support only @nativescript/core and @akylas/nativescript // we should have a more generic way From 6e410da26d79a9583c1a17e045762804dad1ed40 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Fri, 27 Nov 2026 14:15:55 -0300 Subject: [PATCH 2/2] feat(android)!: require NativeScript CLI 9.2+ and drop the node_modules lookup The plugin's own aar build gets core's Android libraries from org.nativescript:gradle-api 0.1.0-alpha.2, which NativeScript CLI 9.2+ loads in that build. Older CLIs get a clear error instead of a path into node_modules. --- .../platforms/android/buildscript.gradle | 2 +- .../platforms/android/include.gradle | 57 +++---------------- 2 files changed, 9 insertions(+), 50 deletions(-) diff --git a/packages/gesturehandler/platforms/android/buildscript.gradle b/packages/gesturehandler/platforms/android/buildscript.gradle index 62ef1e8..270c98c 100644 --- a/packages/gesturehandler/platforms/android/buildscript.gradle +++ b/packages/gesturehandler/platforms/android/buildscript.gradle @@ -2,5 +2,5 @@ repositories { mavenCentral() } dependencies { - classpath "org.nativescript:gradle-api:0.1.0-alpha.1" + classpath "org.nativescript:gradle-api:0.1.0-alpha.2" } diff --git a/packages/gesturehandler/platforms/android/include.gradle b/packages/gesturehandler/platforms/android/include.gradle index 217ebac..31416d5 100644 --- a/packages/gesturehandler/platforms/android/include.gradle +++ b/packages/gesturehandler/platforms/android/include.gradle @@ -1,56 +1,15 @@ -import groovy.json.JsonSlurper - -apply plugin: "org.nativescript.api" - dependencies { implementation "androidx.annotation:annotation:1.1.0" - // In this plugin's own aar build the CLI runs only this block and the next one, and loads - // org.nativescript:gradle-api there only on CLIs that support it, so look the extension up - // instead of assuming it and keep the older code as the fallback. - def ns = project.extensions.findByName("nativescript") - def core = (ns != null && ns.pluginBuild) ? (ns.findPlugin("@nativescript/core") ?: ns.findPlugin("@akylas/nativescript")) : null - if (core != null) { - compileOnly core.artifacts - } else if (project.hasProperty("tempBuild")) { - // we need to copy the code in both places as N main gradle system does not support top level code - // for now we support only @nativescript/core and @akylas/nativescript - // we should have a more generic way - def widgetsDir = "$USER_PROJECT_ROOT/node_modules/@nativescript/core/platforms/android" - def appPackageJsonFile = file("$USER_PROJECT_ROOT/package.json") - if (appPackageJsonFile.exists()) { - def appPackageJson = new JsonSlurper().parseText(appPackageJsonFile.text) - if (appPackageJson.dependencies['@akylas/nativescript'] != null) { - widgetsDir = "$USER_PROJECT_ROOT/node_modules/@akylas/nativescript/platforms/android" - } + if (project.hasProperty("tempBuild")) { + // NativeScript CLIs before 9.2 don't load org.nativescript:gradle-api in this plugin's own aar build. + if (project.extensions.findByName("nativescript") == null) { + throw new GradleException("@nativescript-community/gesturehandler needs NativeScript CLI 9.2 or newer: npm i -D nativescript@latest") } - - // if ui-mobile-base is provided as source the name is nativescript.aar - //else use widget-release.aar - if (file("$widgetsDir/widgets-release.aar").exists()) { - implementation(name:'widgets-release', ext:'aar') - } else { - implementation(name:'nativescript', ext:'aar') + def core = nativescript.findPlugin("@nativescript/core") ?: nativescript.findPlugin("@akylas/nativescript") + if (core == null) { + throw new GradleException("@nativescript-community/gesturehandler needs @nativescript/core or @akylas/nativescript") } + compileOnly core.artifacts } } -repositories { - def ns = project.extensions.findByName("nativescript") - def core = (ns != null && ns.pluginBuild) ? (ns.findPlugin("@nativescript/core") ?: ns.findPlugin("@akylas/nativescript")) : null - if (core == null && project.hasProperty("tempBuild")) { - // we need to copy the code in both places as N main gradle system does not support top level code - // for now we support only @nativescript/core and @akylas/nativescript - // we should have a more generic way - def widgetsDir = "$USER_PROJECT_ROOT/node_modules/@nativescript/core/platforms/android" - def appPackageJsonFile = file("$USER_PROJECT_ROOT/package.json") - if (appPackageJsonFile.exists()) { - def appPackageJson = new JsonSlurper().parseText(appPackageJsonFile.text) - if (appPackageJson.dependencies['@akylas/nativescript'] != null) { - widgetsDir = "$USER_PROJECT_ROOT/node_modules/@akylas/nativescript/platforms/android" - } - } - flatDir { - dirs "$widgetsDir" - } - } -}