Skip to content

Commit

Permalink
android: refine build.gradle get versions
Browse files Browse the repository at this point in the history
Use the same method in https://github.com/oney/react-native-webrtc/pull/494/files
credit: [@maxhawkins](https://github.com/maxhawkins)

And keep fallback version as default.
  • Loading branch information
zxcpoiu committed Aug 13, 2018
1 parent 0d59b74 commit ee38041
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
apply plugin: 'com.android.library'

def _ext = rootProject.ext

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', 23)
buildToolsVersion safeExtGet('buildToolsVersion', "23.0.1")

defaultConfig {
minSdkVersion _minSdkVersion
targetSdkVersion _targetSdkVersion
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 22)
versionCode 1
versionName "1.0"
}
Expand Down

0 comments on commit ee38041

Please sign in to comment.