Skip to content

Commit 238927a

Browse files
authored
little improvement over too many "def"
just added a function which does acts like a ternary with fallback option. Hence, less cluttered "def" variables additionally, changes the SDK values from 23 to 26 as per new changes from react-native and Android Android Target API Level 26 will be required in August 2018. https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html And the React Native team is already working on this: facebook/react-native#18095 facebook/react-native#17741
1 parent 05830ad commit 238927a

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

android/build.gradle

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,19 @@ buildscript {
99

1010
apply plugin: 'com.android.library'
1111

12-
def _ext = rootProject.ext
12+
def safeExtGet(prop, fallback) {
13+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
14+
}
1315

14-
def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
15-
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 23
16-
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '23.0.1'
17-
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16
18-
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 22
19-
def _glideVersion = _ext.has('glideVersion') ? _ext.glideVersion : '4.7.1'
20-
def _excludeAppGlideModule = _ext.has('excludeAppGlideModule') ? _ext.excludeAppGlideModule : false
2116

2217
android {
23-
compileSdkVersion _compileSdkVersion
24-
buildToolsVersion _buildToolsVersion
18+
compileSdkVersion safeExtGet('compileSdkVersion', 26)
19+
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
2520

2621
sourceSets {
2722
main {
2823
java {
29-
if (_excludeAppGlideModule) {
24+
if (safeExtGet('excludeAppGlideModule', false)) {
3025
srcDir 'src'
3126
exclude '**/FastImageGlideModule.java'
3227
}
@@ -35,8 +30,8 @@ android {
3530
}
3631

3732
defaultConfig {
38-
minSdkVersion _minSdkVersion
39-
targetSdkVersion _targetSdkVersion
33+
minSdkVersion safeExtGet('minSdkVersion', 16)
34+
targetSdkVersion safeExtGet('targetSdkVersion', 26)
4035
versionCode 1
4136
versionName "1.0"
4237
}
@@ -54,16 +49,16 @@ repositories {
5449

5550
dependencies {
5651
//noinspection GradleDynamicVersion
57-
compile "com.facebook.react:react-native:${_reactNativeVersion}"
58-
compile "com.android.support:support-v4:${_compileSdkVersion}"
59-
compile("com.github.bumptech.glide:glide:${_glideVersion}") {
52+
compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
53+
compile "com.android.support:support-v4:${safeExtGet('compileSdkVersion', 26)}"
54+
compile("com.github.bumptech.glide:glide:${safeExtGet('glideVersion', 4.7.1)}") {
6055
exclude group: "com.android.support"
6156
}
62-
compile("com.github.bumptech.glide:annotations:${_glideVersion}") {
57+
compile("com.github.bumptech.glide:annotations:${safeExtGet('glideVersion', 4.7.1)}") {
6358
exclude group: "com.android.support"
6459
}
65-
annotationProcessor "com.github.bumptech.glide:compiler:${_glideVersion}"
66-
compile("com.github.bumptech.glide:okhttp3-integration:${_glideVersion}") {
60+
annotationProcessor "com.github.bumptech.glide:compiler:${safeExtGet('glideVersion', 4.7.1)}"
61+
compile("com.github.bumptech.glide:okhttp3-integration:${safeExtGet('glideVersion', 4.7.1)}") {
6762
exclude group: "com.android.support"
6863
exclude group: 'glide-parent'
6964
}

0 commit comments

Comments
 (0)