Gradle resolve react-native version flavor

This commit is contained in:
yogevbd
2019-09-15 20:08:02 +03:00
parent 1081242ba8
commit 35432ac048
2 changed files with 26 additions and 1 deletions

View File

@@ -23,7 +23,6 @@ android {
ndk {
abiFilters "armeabi-v7a", "x86"
}
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
}
buildTypes {
release {

View File

@@ -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 {