Skip to content

Commit cffb112

Browse files
authored
fix(android): support N fork new way of distributing core widgets source code
Removed hardcoded widgets-release dependency and added conditional logic to determine the appropriate AAR file based on project properties.
1 parent 3e94887 commit cffb112

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

packages/ui-cameraview/platforms/android/include.gradle

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import groovy.json.JsonSlurper
33

44
dependencies {
5-
implementation(name:'widgets-release', ext:'aar')
6-
75
def cameraxVersion = project.hasProperty("cameraxVersion") ? project.cameraxVersion : "1.4.0-alpha03"
86
implementation "androidx.camera:camera-core:${cameraxVersion}"
97
implementation "androidx.camera:camera-camera2:${cameraxVersion}"
@@ -25,10 +23,34 @@ dependencies {
2523
def kotlinCoroutine = project.hasProperty("kotlinCoroutine") ? project.kotlinCoroutine : "1.6.4"
2624
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutine"
2725
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutine"
28-
26+
27+
if (project.hasProperty("tempBuild")) {
28+
// we need to copy the code in both places as N main gradle system does not support top level code
29+
// for now we support only @nativescript/core and @akylas/nativescript
30+
// we should have a more generic way
31+
def widgetsDir = "$USER_PROJECT_ROOT/node_modules/@nativescript/core/platforms/android"
32+
def appPackageJsonFile = file("$USER_PROJECT_ROOT/package.json")
33+
if (appPackageJsonFile.exists()) {
34+
def appPackageJson = new JsonSlurper().parseText(appPackageJsonFile.text)
35+
if (appPackageJson.dependencies['@akylas/nativescript'] != null) {
36+
widgetsDir = "$USER_PROJECT_ROOT/node_modules/@akylas/nativescript/platforms/android"
37+
}
38+
}
39+
40+
// if ui-mobile-base is provided as source the name is nativescript.aar
41+
//else use widget-release.aar
42+
if (file("$widgetsDir/widgets-release.aar").exists()) {
43+
implementation(name:'widgets-release', ext:'aar')
44+
} else {
45+
implementation(name:'nativescript', ext:'aar')
46+
}
47+
}
2948
}
3049

3150
repositories {
51+
// we need to copy the code in both places as N main gradle system does not support top level code
52+
// for now we support only @nativescript/core and @akylas/nativescript
53+
// we should have a more generic way
3254
def widgetsDir = "$USER_PROJECT_ROOT/node_modules/@nativescript/core/platforms/android"
3355
def appPackageJsonFile = file("$USER_PROJECT_ROOT/package.json")
3456
if (appPackageJsonFile.exists()) {
@@ -40,4 +62,4 @@ repositories {
4062
flatDir {
4163
dirs "$widgetsDir"
4264
}
43-
}
65+
}

0 commit comments

Comments
 (0)