From 6c946d77f338b15c7ad7e60de5ed9d40197076d0 Mon Sep 17 00:00:00 2001 From: Danish Date: Tue, 24 Jul 2018 17:36:24 +0300 Subject: [PATCH] little improvement over too many "def" just added a function which acts like a ternary with fallback option. Hence, less cluttered "def" variables great to see that lib is supporting already SDK 27 --- android/build.gradle | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 789f4345..a57d7a46 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,20 +1,16 @@ apply plugin: 'com.android.library' -def _ext = rootProject.ext - -def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+' -def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 27 -def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '27.0.3' -def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16 -def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 27 +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} android { - compileSdkVersion _compileSdkVersion - buildToolsVersion _buildToolsVersion + compileSdkVersion safeExtGet('compileSdkVersion', 27) + buildToolsVersion safeExtGet('buildToolsVersion', '27.0.3') defaultConfig { - minSdkVersion _minSdkVersion - targetSdkVersion _targetSdkVersion + minSdkVersion safeExtGet('minSdkVersion', 16) + targetSdkVersion safeExtGet('targetSdkVersion', 27) versionCode 1 versionName "1.0" ndk { @@ -25,6 +21,6 @@ android { dependencies { //noinspection GradleDynamicVersion - provided "com.facebook.react:react-native:${_reactNativeVersion}" + provided "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" compile 'com.yqritc:android-scalablevideoview:1.0.4' }