mirror of
https://github.com/zhigang1992/react-native-notifications.git
synced 2026-06-11 08:13:28 +08:00
Gradle resolve react-native version flavor
This commit is contained in:
@@ -23,7 +23,6 @@ android {
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply from: '../prepare-robolectric.gradle'
|
||||
|
||||
String resolveFlavor() {
|
||||
def packageSlurper = new JsonSlurper()
|
||||
def reactNativePackageJson = packageSlurper.parse file('../../node_modules/react-native/package.json')
|
||||
def reactNativeVersion = reactNativePackageJson.version
|
||||
|
||||
List versionComponents = reactNativeVersion.tokenize('.')
|
||||
|
||||
if (versionComponents[1].toInteger() < 60) {
|
||||
return "reactNative59"
|
||||
} else {
|
||||
return "reactNative60"
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion '28.0.3'
|
||||
@@ -11,6 +27,7 @@ android {
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
@@ -20,6 +37,7 @@ android {
|
||||
debuggable true
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.all { t ->
|
||||
reports {
|
||||
@@ -49,6 +67,14 @@ android {
|
||||
dimension "RNNotifications.reactNativeVersion"
|
||||
}
|
||||
}
|
||||
|
||||
def flavor = resolveFlavor()
|
||||
variantFilter { variant ->
|
||||
def names = variant.flavors*.name
|
||||
if (!names.contains(flavor)) {
|
||||
setIgnore(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
Reference in New Issue
Block a user