1
- import java.nio.file.Paths
2
- import com.android.Version
3
-
4
- def agpVersion = com.android.Version . ANDROID_GRADLE_PLUGIN_VERSION
5
- def agpVersionMajor = agpVersion. tokenize(' .' )[0 ]. toInteger()
6
- def agpVersionMinor = agpVersion. tokenize(' .' )[1 ]. toInteger()
7
-
8
1
buildscript {
9
2
repositories {
10
- maven {
11
- url " https://plugins.gradle.org/m2/"
12
- }
13
- mavenCentral()
14
3
google()
4
+ mavenCentral()
15
5
}
16
6
17
7
dependencies {
18
- classpath( " com.android.tools.build:gradle:8.3 .1" )
8
+ classpath " com.android.tools.build:gradle:7.2 .1"
19
9
}
20
10
}
21
11
22
- def isNewArchitectureEnabled () {
23
- // To opt-in for the New Architecture, you can either:
24
- // - Set `newArchEnabled` to true inside the `gradle.properties` file
25
- // - Invoke gradle with `-newArchEnabled=true`
26
- // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
27
- return project. hasProperty(" newArchEnabled" ) && project. newArchEnabled == " true"
12
+ def reactNativeArchitectures () {
13
+ def value = rootProject. getProperties(). get(" reactNativeArchitectures" )
14
+ return value ? value. split(" ," ) : [" armeabi-v7a" , " x86" , " x86_64" , " arm64-v8a" ]
28
15
}
29
16
30
- def resolveBuildType () {
31
- Gradle gradle = getGradle()
32
- String tskReqStr = gradle. getStartParameter(). getTaskRequests()[' args' ]. toString()
33
-
34
- return tskReqStr. contains(' Release' ) ? ' release' : ' debug'
17
+ def isNewArchitectureEnabled () {
18
+ return rootProject. hasProperty(" newArchEnabled" ) && rootProject. getProperty(" newArchEnabled" ) == " true"
35
19
}
36
20
37
- apply plugin : ' com.android.library'
21
+ apply plugin : " com.android.library"
38
22
apply plugin : ' org.jetbrains.kotlin.android'
39
23
apply from : ' ../nitrogen/generated/android/QuickCrypto+autolinking.gradle'
40
24
41
25
if (isNewArchitectureEnabled()) {
42
26
apply plugin : " com.facebook.react"
43
27
}
44
28
45
- def safeExtGet (prop , fallback ) {
46
- rootProject. ext. has(prop) ? rootProject. ext. get(prop) : fallback
47
- }
48
-
49
- def reactNativeArchitectures () {
50
- def value = project. getProperties(). get(" reactNativeArchitectures" )
51
- return value ? value. split(" ," ) : [" armeabi-v7a" , " x86" , " x86_64" , " arm64-v8a" ]
52
- }
53
-
54
- static def findNodeModules (baseDir ) {
55
- def basePath = baseDir. toPath(). normalize()
56
- // Node's module resolution algorithm searches up to the root directory,
57
- // after which the base path will be null
58
- while (basePath) {
59
- def nodeModulesPath = Paths . get(basePath. toString(), " node_modules" )
60
- def reactNativePath = Paths . get(nodeModulesPath. toString(), " react-native" )
61
- if (nodeModulesPath. toFile(). exists() && reactNativePath. toFile(). exists()) {
62
- return nodeModulesPath. toString()
63
- }
64
- basePath = basePath. getParent()
65
- }
66
- throw new GradleException (" react-native-quick-crypto: Failed to find node_modules/ path!" )
29
+ def getExtOrDefault (name ) {
30
+ return rootProject. ext. has(name) ? rootProject. ext. get(name) : project. properties[" Nitro_" + name]
67
31
}
68
32
69
- def nodeModules = findNodeModules(projectDir)
70
-
71
- repositories {
72
- google()
73
- mavenCentral()
33
+ def getExtOrIntegerDefault (name ) {
34
+ return rootProject. ext. has(name) ? rootProject. ext. get(name) : (project. properties[" Nitro_" + name]). toInteger()
74
35
}
75
36
76
37
android {
77
- compileSdkVersion safeExtGet( " compileSdkVersion " , 31 )
38
+ namespace " com.margelo.nitro.quickcrypto "
78
39
79
- if ((agpVersionMajor == 7 && agpVersionMinor >= 3 ) || agpVersionMajor >= 8 ) {
80
- // Namespace support was added in 7.3.0
81
- namespace " com.margelo.quickcrypto"
82
-
83
- sourceSets {
84
- main {
85
- manifest. srcFile " src/main/AndroidManifestNew.xml"
86
- }
87
- }
88
- }
89
-
90
- if (agpVersionMajor >= 8 ) {
91
- buildFeatures {
92
- buildConfig = true
93
- }
94
- }
95
-
96
- // Used to override the NDK path/version on internal CI or by allowing
97
- // users to customize the NDK path/version from their root project (e.g. for M1 support)
98
- if (rootProject. hasProperty(" ndkPath" )) {
99
- ndkPath rootProject. ext. ndkPath
100
- }
101
- if (rootProject. hasProperty(" ndkVersion" )) {
102
- ndkVersion rootProject. ext. ndkVersion
103
- }
104
-
105
- buildFeatures {
106
- prefab true
107
- }
40
+ ndkVersion getExtOrDefault(" ndkVersion" )
41
+ compileSdkVersion getExtOrIntegerDefault(" compileSdkVersion" )
108
42
109
43
defaultConfig {
110
- minSdkVersion safeExtGet(' minSdkVersion' , 28 )
111
- targetSdkVersion safeExtGet(' targetSdkVersion' , 31 )
112
- versionCode 1
113
- versionName " 1.0"
44
+ minSdkVersion getExtOrIntegerDefault(" minSdkVersion" )
45
+ targetSdkVersion getExtOrIntegerDefault(" targetSdkVersion" )
114
46
buildConfigField " boolean" , " IS_NEW_ARCHITECTURE_ENABLED" , isNewArchitectureEnabled(). toString()
47
+
115
48
externalNativeBuild {
116
49
cmake {
117
- cppFlags " -O2 -frtti -fexceptions -Wall -Wno-unused-variable - fstack-protector-all -DANDROID "
118
- arguments " -DANDROID_STL=c++_shared" , " -DNODE_MODULES_DIR= ${ nodeModules } "
50
+ cppFlags " -O2 -frtti -fexceptions -Wall -fstack-protector-all"
51
+ arguments " -DANDROID_STL=c++_shared"
119
52
abiFilters (* reactNativeArchitectures())
120
53
}
121
54
}
@@ -127,67 +60,64 @@ android {
127
60
}
128
61
}
129
62
130
- packagingOptions {
131
- doNotStrip resolveBuildType() == ' debug' ? " **/**/*.so" : ' '
132
- excludes = [
133
- " **/libc++_shared.so" ,
134
- " **/libfbjni.so" ,
135
- " **/libreactnativejni.so" ,
136
- " **/libjsi.so" ,
137
- " **/libreact_nativemodule_core.so" ,
138
- " **/libturbomodulejsijni.so" ,
139
- " **/MANIFEST.MF" ,
140
- ]
63
+ buildFeatures {
64
+ buildConfig true
65
+ prefab true
141
66
}
142
67
143
68
buildTypes {
144
69
release {
145
70
minifyEnabled false
146
71
}
147
- debug {
148
- packagingOptions {
149
- doNotStrip ' **/*.so'
150
- }
151
- minifyEnabled false
152
- debuggable true
153
- jniDebuggable true
154
- renderscriptDebuggable true
155
- }
156
72
}
157
73
158
74
lintOptions {
159
- disable ' GradleCompatible'
75
+ disable " GradleCompatible"
160
76
}
77
+
161
78
compileOptions {
162
79
sourceCompatibility JavaVersion . VERSION_1_8
163
80
targetCompatibility JavaVersion . VERSION_1_8
164
81
}
165
82
83
+ sourceSets {
84
+ main {
85
+ if (isNewArchitectureEnabled()) {
86
+ java. srcDirs + = [
87
+ // React Codegen files
88
+ " ${ project.buildDir} /generated/source/codegen/java"
89
+ ]
90
+ }
91
+ }
92
+ }
166
93
}
167
94
168
95
repositories {
169
96
mavenCentral()
170
97
google()
171
98
}
172
99
100
+
173
101
dependencies {
102
+ // For < 0.71, this will be from the local maven repo
103
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
174
104
// noinspection GradleDynamicVersion
175
- implementation " com.facebook.react:react-android:+"
176
- // https://mvnrepository.com/artifact/com.android.ndk.thirdparty/openssl
177
- implementation ' com.android.ndk.thirdparty:openssl:1.1.1q-beta-1'
105
+ implementation " com.facebook.react:react-native:+"
106
+
107
+ // Add a dependency on NitroModules
108
+ implementation project(" :react-native-nitro-modules" )
109
+
110
+ // Add a dependency on React Native Screens
111
+ implementation project(' :react-native-screens' )
112
+
113
+ // Add a dependency on React Native Vector Icons
114
+ implementation project(' :react-native-vector-icons' )
178
115
}
179
116
180
- // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
181
- tasks. whenTaskAdded { task ->
182
- if (task. name. contains(" configureCMakeDebug" )) {
183
- rootProject. getTasksByName(" packageReactNdkDebugLibs" , true ). forEach {
184
- task. dependsOn(it)
185
- }
186
- }
187
- // We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo
188
- if (task. name. contains(" configureCMakeRel" )) {
189
- rootProject. getTasksByName(" packageReactNdkReleaseLibs" , true ). forEach {
190
- task. dependsOn(it)
191
- }
117
+ if (isNewArchitectureEnabled()) {
118
+ react {
119
+ jsRootDir = file(" ../src/" )
120
+ libraryName = " QuickCrypto"
121
+ codegenJavaPackageName = " com.margelo.nitro.quickcrypto"
192
122
}
193
- }
123
+ }
0 commit comments