From 2cae53755b1cea6fa3b47e4d3e0ed45bdf6f50bb Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Mon, 23 Nov 2026 16:23:54 -0300 Subject: [PATCH] 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