1
1
buildscript {
2
- ext {
3
- kotlinVersion = ' 1.6.0'
4
- buildToolsVersion = ' 29.0.2'
5
- compileSdkVersion = 29
6
- targetSdkVersion = 29
7
- minSdkVersion = 18
8
- }
9
- ext. detoxKotlinVersion = ext. kotlinVersion
2
+ def kotlinVersion = rootProject. ext. has(" kotlinVersion" ) ? rootProject. ext. get(" kotlinVersion" ) : project. properties[" RNBGU_kotlinVersion" ]
3
+ ext. detoxKotlinVersion = kotlinVersion
10
4
11
5
repositories {
12
- mavenCentral()
13
6
google()
7
+ mavenCentral()
14
8
}
15
9
dependencies {
16
- classpath ' com.android.tools.build:gradle:3.5.3 '
10
+ classpath " com.android.tools.build:gradle:7.4.2 "
17
11
classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
18
12
}
19
13
}
20
14
21
15
apply plugin : ' com.android.library'
22
16
apply plugin : ' kotlin-android'
23
- apply plugin : ' kotlin-android-extensions'
24
17
25
- def DEFAULT_COMPILE_SDK_VERSION = 28
26
- def DEFAULT_BUILD_TOOLS_VERSION = " 28.0.3 "
27
- def DEFAULT_TARGET_SDK_VERSION = 28
18
+ def getExtOrDefault ( name ) {
19
+ return rootProject . ext . has(name) ? rootProject . ext . get(name) : project . properties[ " RNBGU_ " + name]
20
+ }
28
21
29
- def safeExtGet ( prop , fallback ) {
30
- rootProject. ext. has(prop ) ? rootProject. ext. get(prop ) : fallback
22
+ def getExtOrIntegerDefault ( name ) {
23
+ return rootProject. ext. has(name ) ? rootProject. ext. get(name ) : (project . properties[ " RNBGU_ " + name]) . toInteger()
31
24
}
32
25
33
26
android {
34
- compileSdkVersion safeExtGet(' compileSdkVersion' , DEFAULT_COMPILE_SDK_VERSION )
35
- buildToolsVersion safeExtGet(' buildToolsVersion' , DEFAULT_BUILD_TOOLS_VERSION )
27
+ compileSdkVersion getExtOrIntegerDefault(" compileSdkVersion" )
36
28
37
29
defaultConfig {
38
- minSdkVersion 21
39
- targetSdkVersion safeExtGet(' targetSdkVersion' , DEFAULT_TARGET_SDK_VERSION )
40
- versionCode 1
41
- versionName " 1.0"
42
- ndk {
43
- abiFilters " armeabi-v7a" , " x86"
44
- }
30
+ minSdkVersion getExtOrIntegerDefault(" minSdkVersion" )
31
+ targetSdkVersion getExtOrIntegerDefault(" targetSdkVersion" )
45
32
}
33
+
46
34
lintOptions {
47
35
abortOnError false
48
36
}
49
37
}
50
38
51
39
repositories {
40
+ google()
52
41
mavenCentral()
53
- }
54
42
55
- def _ext = ext
43
+ def found = false
44
+ def defaultDir = null
45
+ def androidSourcesName = " React Native sources"
56
46
57
- def _kotlinVersion = _ext. has(' detoxKotlinVersion' ) ? _ext. detoxKotlinVersion : ' 1.3.10'
58
- def _kotlinStdlib = _ext. has(' detoxKotlinStdlib' ) ? _ext. detoxKotlinStdlib : ' kotlin-stdlib-jdk8'
47
+ if (rootProject. ext. has(" reactNativeAndroidRoot" )) {
48
+ defaultDir = rootProject. ext. get(" reactNativeAndroidRoot" )
49
+ } else {
50
+ defaultDir = new File (
51
+ projectDir,
52
+ " /../../../node_modules/react-native/android"
53
+ )
54
+ }
59
55
60
- dependencies {
61
- implementation " androidx.core:core-ktx:1.0.1"
56
+ if (defaultDir. exists()) {
57
+ maven {
58
+ url defaultDir. toString()
59
+ name androidSourcesName
60
+ }
61
+
62
+ logger. info(" :${ project.name} :reactNativeAndroidRoot ${ defaultDir.canonicalPath} " )
63
+ found = true
64
+ } else {
65
+ def parentDir = rootProject. projectDir
66
+
67
+ 1. upto(5 , {
68
+ if (found) return true
69
+ parentDir = parentDir. parentFile
62
70
63
- implementation ' com.facebook.react:react-native:+'
71
+ def androidSourcesDir = new File (
72
+ parentDir,
73
+ " node_modules/react-native"
74
+ )
64
75
65
- implementation " org.jetbrains.kotlin:$_kotlinStdlib :$_kotlinVersion "
76
+ def androidPrebuiltBinaryDir = new File (
77
+ parentDir,
78
+ " node_modules/react-native/android"
79
+ )
66
80
67
- implementation ' net.gotev:uploadservice-okhttp:4.7.0'
81
+ if (androidPrebuiltBinaryDir. exists()) {
82
+ maven {
83
+ url androidPrebuiltBinaryDir. toString()
84
+ name androidSourcesName
85
+ }
68
86
69
- implementation ' androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
87
+ logger. info(" :${ project.name} :reactNativeAndroidRoot ${ androidPrebuiltBinaryDir.canonicalPath} " )
88
+ found = true
89
+ } else if (androidSourcesDir. exists()) {
90
+ maven {
91
+ url androidSourcesDir. toString()
92
+ name androidSourcesName
93
+ }
94
+
95
+ logger. info(" :${ project.name} :reactNativeAndroidRoot ${ androidSourcesDir.canonicalPath} " )
96
+ found = true
97
+ }
98
+ })
99
+ }
100
+
101
+ if (! found) {
102
+ throw new GradleException (
103
+ " ${ project.name} : unable to locate React Native android sources. " +
104
+ " Ensure you have you installed React Native as a dependency in your project and try again."
105
+ )
106
+ }
70
107
}
108
+
109
+ def kotlinVersion = getExtOrDefault(" kotlinVersion" )
110
+
111
+ dependencies {
112
+ implementation " androidx.core:core-ktx:1.12.0"
113
+
114
+ implementation " com.facebook.react:react-native:+"
115
+
116
+ implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion "
117
+
118
+ implementation ' net.gotev:uploadservice-okhttp:4.9.2'
119
+
120
+ implementation ' androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
121
+ }
0 commit comments