diff --git a/packages/gesturehandler/platforms/android/buildscript.gradle b/packages/gesturehandler/platforms/android/buildscript.gradle new file mode 100644 index 0000000..270c98c --- /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.2" +} diff --git a/packages/gesturehandler/platforms/android/include.gradle b/packages/gesturehandler/platforms/android/include.gradle index 2ff6bb2..31416d5 100644 --- a/packages/gesturehandler/platforms/android/include.gradle +++ b/packages/gesturehandler/platforms/android/include.gradle @@ -1,45 +1,15 @@ -import groovy.json.JsonSlurper - dependencies { implementation "androidx.annotation:annotation:1.1.0" 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" - } + // 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 { - 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" - } - } - flatDir { - dirs "$widgetsDir" - } - } -}