Skip to content

Commit

Permalink
little improvement over too many "def"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yeomann committed Jul 24, 2018
1 parent 05830ad commit 238927a
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@ buildscript {

apply plugin: 'com.android.library'

def _ext = rootProject.ext
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 23
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '23.0.1'
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 22
def _glideVersion = _ext.has('glideVersion') ? _ext.glideVersion : '4.7.1'
def _excludeAppGlideModule = _ext.has('excludeAppGlideModule') ? _ext.excludeAppGlideModule : false

android {
compileSdkVersion _compileSdkVersion
buildToolsVersion _buildToolsVersion
compileSdkVersion safeExtGet('compileSdkVersion', 26)
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')

sourceSets {
main {
java {
if (_excludeAppGlideModule) {
if (safeExtGet('excludeAppGlideModule', false)) {
srcDir 'src'
exclude '**/FastImageGlideModule.java'
}
Expand All @@ -35,8 +30,8 @@ android {
}

defaultConfig {
minSdkVersion _minSdkVersion
targetSdkVersion _targetSdkVersion
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 26)
versionCode 1
versionName "1.0"
}
Expand All @@ -54,16 +49,16 @@ repositories {

dependencies {
//noinspection GradleDynamicVersion
compile "com.facebook.react:react-native:${_reactNativeVersion}"
compile "com.android.support:support-v4:${_compileSdkVersion}"
compile("com.github.bumptech.glide:glide:${_glideVersion}") {
compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
compile "com.android.support:support-v4:${safeExtGet('compileSdkVersion', 26)}"
compile("com.github.bumptech.glide:glide:${safeExtGet('glideVersion', 4.7.1)}") {
exclude group: "com.android.support"
}
compile("com.github.bumptech.glide:annotations:${_glideVersion}") {
compile("com.github.bumptech.glide:annotations:${safeExtGet('glideVersion', 4.7.1)}") {
exclude group: "com.android.support"
}
annotationProcessor "com.github.bumptech.glide:compiler:${_glideVersion}"
compile("com.github.bumptech.glide:okhttp3-integration:${_glideVersion}") {
annotationProcessor "com.github.bumptech.glide:compiler:${safeExtGet('glideVersion', 4.7.1)}"
compile("com.github.bumptech.glide:okhttp3-integration:${safeExtGet('glideVersion', 4.7.1)}") {
exclude group: "com.android.support"
exclude group: 'glide-parent'
}
Expand Down

0 comments on commit 238927a

Please sign in to comment.