@@ -2,13 +2,18 @@ import java.nio.file.Paths
2
2
import org.apache.tools.ant.taskdefs.condition.Os
3
3
4
4
buildscript {
5
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
6
+ def kotlin_version = rootProject. ext. has(" kotlinVersion" ) ? rootProject. ext. get(" kotlinVersion" ) : project. properties[" PkceChallenge_kotlinVersion" ]
7
+
5
8
repositories {
6
9
google()
7
10
mavenCentral()
8
11
}
9
12
10
13
dependencies {
11
14
classpath " com.android.tools.build:gradle:7.2.1"
15
+ // noinspection DifferentKotlinGradleVersion
16
+ classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version "
12
17
}
13
18
}
14
19
@@ -33,11 +38,17 @@ static def findNodeModules(baseDir) {
33
38
34
39
def nodeModules = findNodeModules(projectDir)
35
40
41
+ def reactNativeArchitectures () {
42
+ def value = rootProject. getProperties(). get(" reactNativeArchitectures" )
43
+ return value ? value. split(" ," ) : [" armeabi-v7a" , " x86" , " x86_64" , " arm64-v8a" ]
44
+ }
45
+
36
46
def isNewArchitectureEnabled () {
37
47
return rootProject. hasProperty(" newArchEnabled" ) && rootProject. getProperty(" newArchEnabled" ) == " true"
38
48
}
39
49
40
50
apply plugin : " com.android.library"
51
+ apply plugin : " kotlin-android"
41
52
42
53
if (isNewArchitectureEnabled()) {
43
54
apply plugin : " com.facebook.react"
@@ -77,11 +88,13 @@ android {
77
88
defaultConfig {
78
89
minSdkVersion getExtOrIntegerDefault(" minSdkVersion" )
79
90
targetSdkVersion getExtOrIntegerDefault(" targetSdkVersion" )
91
+ buildConfigField " boolean" , " IS_NEW_ARCHITECTURE_ENABLED" , isNewArchitectureEnabled(). toString()
80
92
81
93
externalNativeBuild {
82
94
cmake {
83
95
cppFlags " -O2 -frtti -fexceptions -Wall -fstack-protector-all"
84
96
arguments " -DNODE_MODULES_DIR=${ nodeModules} "
97
+ abiFilters (* reactNativeArchitectures())
85
98
}
86
99
}
87
100
}
@@ -92,6 +105,10 @@ android {
92
105
}
93
106
}
94
107
108
+ buildFeatures {
109
+ buildConfig true
110
+ }
111
+
95
112
buildTypes {
96
113
release {
97
114
minifyEnabled false
@@ -106,18 +123,38 @@ android {
106
123
sourceCompatibility JavaVersion . VERSION_1_8
107
124
targetCompatibility JavaVersion . VERSION_1_8
108
125
}
126
+
127
+ sourceSets {
128
+ main {
129
+ if (isNewArchitectureEnabled()) {
130
+ java. srcDirs + = [
131
+ " generated/java" ,
132
+ " generated/jni"
133
+ ]
134
+ }
135
+ }
136
+ }
109
137
}
110
138
111
139
repositories {
112
140
mavenCentral()
113
141
google()
114
142
}
115
143
144
+ def kotlin_version = getExtOrDefault(" kotlinVersion" )
116
145
117
146
dependencies {
118
147
// For < 0.71, this will be from the local maven repo
119
148
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
120
149
// noinspection GradleDynamicVersion
121
150
implementation " com.facebook.react:react-native:+"
151
+ implementation " org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version "
122
152
}
123
153
154
+ if (isNewArchitectureEnabled()) {
155
+ react {
156
+ jsRootDir = file(" ../src/" )
157
+ libraryName = " PkceChallenge"
158
+ codegenJavaPackageName = " com.pkcechallenge"
159
+ }
160
+ }
0 commit comments