Skip to content

Commit 53ae865

Browse files
committed
chore: upgrade package build.gradle
1 parent 2a04d51 commit 53ae865

File tree

1 file changed

+64
-74
lines changed

1 file changed

+64
-74
lines changed

package/android/build.gradle

Lines changed: 64 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,115 @@
1-
import java.nio.file.Paths
2-
31
buildscript {
42
repositories {
5-
maven {
6-
url "https://plugins.gradle.org/m2/"
7-
}
8-
mavenCentral()
93
google()
4+
mavenCentral()
105
}
116

127
dependencies {
13-
classpath("com.android.tools.build:gradle:7.2.2")
8+
classpath "com.android.tools.build:gradle:7.2.2"
149
}
1510
}
1611

17-
def resolveBuildType() {
18-
Gradle gradle = getGradle()
19-
String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
20-
21-
return tskReqStr.contains('Release') ? 'release' : 'debug'
12+
def reactNativeArchitectures() {
13+
def value = rootProject.getProperties().get("reactNativeArchitectures")
14+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
2215
}
2316

2417
def isNewArchitectureEnabled() {
25-
// - Set `newArchEnabled` to true inside the `gradle.properties` file
26-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
18+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
2719
}
2820

2921
def SQLITE_FLAGS = rootProject.properties['quickSqliteFlags']
3022

31-
apply plugin: 'com.android.library'
23+
apply plugin: "com.android.library"
24+
apply plugin: 'org.jetbrains.kotlin.android'
3225

33-
def safeExtGet(prop, fallback) {
34-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
26+
if (isNewArchitectureEnabled()) {
27+
apply plugin: "com.facebook.react"
3528
}
3629

37-
def reactNativeArchitectures() {
38-
def value = project.getProperties().get("reactNativeArchitectures")
39-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
30+
def getExtOrDefault(name) {
31+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNQuickSQLite_" + name]
4032
}
4133

42-
def USE_HERMES = rootProject.ext.hermesEnabled
43-
44-
repositories {
45-
mavenCentral()
34+
def getExtOrIntegerDefault(name) {
35+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNQuickSQLite_" + name]).toInteger()
4636
}
4737

4838
android {
49-
compileSdkVersion safeExtGet("compileSdkVersion", 28)
39+
namespace "com.margelo.rnquicksqlite"
40+
41+
ndkVersion getExtOrDefault("ndkVersion")
42+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
43+
44+
defaultConfig {
45+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
46+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
47+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
5048

51-
// Used to override the NDK path/version on internal CI or by allowing
52-
// users to customize the NDK path/version from their root project (e.g. for M1 support)
53-
if (rootProject.hasProperty("ndkPath")) {
54-
ndkPath rootProject.ext.ndkPath
49+
externalNativeBuild {
50+
cmake {
51+
cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID", "-Wall", "-fstack-protector-all"
52+
arguments "-DANDROID_STL=c++_shared", "-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'"
53+
abiFilters (*reactNativeArchitectures())
54+
}
55+
}
5556
}
56-
if (rootProject.hasProperty("ndkVersion")) {
57-
ndkVersion rootProject.ext.ndkVersion
57+
58+
externalNativeBuild {
59+
cmake {
60+
path "CMakeLists.txt"
61+
}
5862
}
5963

6064
buildFeatures {
65+
buildConfig true
6166
prefab true
6267
}
6368

64-
defaultConfig {
65-
minSdkVersion safeExtGet("minSdkVersion", 21)
66-
targetSdkVersion safeExtGet('targetSdkVersion', 28)
67-
versionCode 1
68-
versionName "1.0"
69-
70-
externalNativeBuild {
71-
cmake {
72-
cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
73-
arguments '-DANDROID_STL=c++_shared',
74-
"-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'",
75-
"-DUSE_HERMES=${USE_HERMES}"
76-
abiFilters (*reactNativeArchitectures())
77-
}
69+
buildTypes {
70+
release {
71+
minifyEnabled false
7872
}
73+
}
7974

80-
packagingOptions {
81-
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
82-
excludes = [
83-
"META-INF",
84-
"META-INF/**",
85-
"**/libjsi.so",
86-
"**/libreact_nativemodule_core.so",
87-
"**/libturbomodulejsijni.so",
88-
"**/libc++_shared.so",
89-
"**/libfbjni.so"
90-
]
91-
}
75+
lintOptions {
76+
disable "GradleCompatible"
9277
}
9378

9479
compileOptions {
9580
sourceCompatibility JavaVersion.VERSION_1_8
9681
targetCompatibility JavaVersion.VERSION_1_8
9782
}
9883

99-
externalNativeBuild {
100-
cmake {
101-
path "CMakeLists.txt"
84+
sourceSets {
85+
main {
86+
if (isNewArchitectureEnabled()) {
87+
java.srcDirs += [
88+
// React Codegen files
89+
"${project.buildDir}/generated/source/codegen/java"
90+
]
91+
}
10292
}
10393
}
10494
}
10595

96+
repositories {
97+
mavenCentral()
98+
google()
99+
}
100+
101+
106102
dependencies {
103+
// For < 0.71, this will be from the local maven repo
104+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
107105
//noinspection GradleDynamicVersion
108-
implementation 'com.facebook.react:react-android:+'
109-
implementation 'com.facebook.fbjni:fbjni:+'
106+
implementation "com.facebook.react:react-native:+"
110107
}
111108

112-
// Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
113-
tasks.whenTaskAdded { task ->
114-
if (task.name.contains("configureCMakeDebug")) {
115-
rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach {
116-
task.dependsOn(it)
117-
}
118-
}
119-
// We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo
120-
if (task.name.contains("configureCMakeRel")) {
121-
rootProject.getTasksByName("packageReactNdkReleaseLibs", true).forEach {
122-
task.dependsOn(it)
123-
}
109+
if (isNewArchitectureEnabled()) {
110+
react {
111+
jsRootDir = file("../src/")
112+
libraryName = "RNQuickSQLite"
113+
codegenJavaPackageName = "com.margelo.rnquicksqlite"
124114
}
125115
}

0 commit comments

Comments
 (0)