|
1 | | -import java.nio.file.Paths |
2 | | - |
3 | 1 | buildscript { |
4 | 2 | repositories { |
5 | | - maven { |
6 | | - url "https://plugins.gradle.org/m2/" |
7 | | - } |
8 | | - mavenCentral() |
9 | 3 | google() |
| 4 | + mavenCentral() |
10 | 5 | } |
11 | 6 |
|
12 | 7 | dependencies { |
13 | | - classpath("com.android.tools.build:gradle:7.2.2") |
| 8 | + classpath "com.android.tools.build:gradle:7.2.2" |
14 | 9 | } |
15 | 10 | } |
16 | 11 |
|
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"] |
22 | 15 | } |
23 | 16 |
|
24 | 17 | 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" |
27 | 19 | } |
28 | 20 |
|
29 | 21 | def SQLITE_FLAGS = rootProject.properties['quickSqliteFlags'] |
30 | 22 |
|
31 | | -apply plugin: 'com.android.library' |
| 23 | +apply plugin: "com.android.library" |
| 24 | +apply plugin: 'org.jetbrains.kotlin.android' |
32 | 25 |
|
33 | | -def safeExtGet(prop, fallback) { |
34 | | - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback |
| 26 | +if (isNewArchitectureEnabled()) { |
| 27 | + apply plugin: "com.facebook.react" |
35 | 28 | } |
36 | 29 |
|
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] |
40 | 32 | } |
41 | 33 |
|
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() |
46 | 36 | } |
47 | 37 |
|
48 | 38 | 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() |
50 | 48 |
|
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 | + } |
55 | 56 | } |
56 | | - if (rootProject.hasProperty("ndkVersion")) { |
57 | | - ndkVersion rootProject.ext.ndkVersion |
| 57 | + |
| 58 | + externalNativeBuild { |
| 59 | + cmake { |
| 60 | + path "CMakeLists.txt" |
| 61 | + } |
58 | 62 | } |
59 | 63 |
|
60 | 64 | buildFeatures { |
| 65 | + buildConfig true |
61 | 66 | prefab true |
62 | 67 | } |
63 | 68 |
|
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 |
78 | 72 | } |
| 73 | + } |
79 | 74 |
|
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" |
92 | 77 | } |
93 | 78 |
|
94 | 79 | compileOptions { |
95 | 80 | sourceCompatibility JavaVersion.VERSION_1_8 |
96 | 81 | targetCompatibility JavaVersion.VERSION_1_8 |
97 | 82 | } |
98 | 83 |
|
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 | + } |
102 | 92 | } |
103 | 93 | } |
104 | 94 | } |
105 | 95 |
|
| 96 | +repositories { |
| 97 | + mavenCentral() |
| 98 | + google() |
| 99 | +} |
| 100 | + |
| 101 | + |
106 | 102 | 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 |
107 | 105 | //noinspection GradleDynamicVersion |
108 | | - implementation 'com.facebook.react:react-android:+' |
109 | | - implementation 'com.facebook.fbjni:fbjni:+' |
| 106 | + implementation "com.facebook.react:react-native:+" |
110 | 107 | } |
111 | 108 |
|
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" |
124 | 114 | } |
125 | 115 | } |
0 commit comments