|
| 1 | +buildscript { |
| 2 | + // Buildscript is evaluated before everything else so we can't use getExtOrDefault |
| 3 | + def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SqliteStorage_kotlinVersion"] |
| 4 | + |
| 5 | + repositories { |
| 6 | + google() |
| 7 | + mavenCentral() |
| 8 | + } |
| 9 | + |
| 10 | + dependencies { |
| 11 | + classpath "com.android.tools.build:gradle:7.2.1" |
| 12 | + // noinspection DifferentKotlinGradleVersion |
| 13 | + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +def isNewArchitectureEnabled() { |
| 18 | + return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" |
| 19 | +} |
| 20 | + |
| 21 | +apply plugin: "com.android.library" |
| 22 | +apply plugin: "kotlin-android" |
| 23 | + |
| 24 | +if (isNewArchitectureEnabled()) { |
| 25 | + apply plugin: "com.facebook.react" |
| 26 | +} |
| 27 | + |
| 28 | +def getExtOrDefault(name) { |
| 29 | + return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["SqliteStorage_" + name] |
| 30 | +} |
| 31 | + |
| 32 | +def getExtOrIntegerDefault(name) { |
| 33 | + return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["SqliteStorage_" + name]).toInteger() |
| 34 | +} |
| 35 | + |
| 36 | +def supportsNamespace() { |
| 37 | + def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.') |
| 38 | + def major = parsed[0].toInteger() |
| 39 | + def minor = parsed[1].toInteger() |
| 40 | + |
| 41 | + // Namespace support was added in 7.3.0 |
| 42 | + return (major == 7 && minor >= 3) || major >= 8 |
| 43 | +} |
| 44 | + |
| 45 | +android { |
| 46 | + if (supportsNamespace()) { |
| 47 | + namespace "org.rnasyncstorage.sqlitestorage" |
| 48 | + |
| 49 | + sourceSets { |
| 50 | + main { |
| 51 | + manifest.srcFile "src/main/AndroidManifestNew.xml" |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") |
| 57 | + |
| 58 | + defaultConfig { |
| 59 | + minSdkVersion getExtOrIntegerDefault("minSdkVersion") |
| 60 | + targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | + buildTypes { |
| 65 | + release { |
| 66 | + minifyEnabled false |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + lintOptions { |
| 71 | + disable "GradleCompatible" |
| 72 | + } |
| 73 | + |
| 74 | + compileOptions { |
| 75 | + sourceCompatibility JavaVersion.VERSION_1_8 |
| 76 | + targetCompatibility JavaVersion.VERSION_1_8 |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +repositories { |
| 81 | + mavenCentral() |
| 82 | + google() |
| 83 | +} |
| 84 | + |
| 85 | +def kotlin_version = getExtOrDefault("kotlinVersion") |
| 86 | + |
| 87 | +dependencies { |
| 88 | + // For < 0.71, this will be from the local maven repo |
| 89 | + // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin |
| 90 | + //noinspection GradleDynamicVersion |
| 91 | + implementation "com.facebook.react:react-native:+" |
| 92 | + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" |
| 93 | +} |
| 94 | + |
0 commit comments