fix(Gradle): Allow kotlinVersion override using ext with gradle.properties (#267)

You can now override kotlin version by defining ext kotlinVersion
This commit is contained in:
Thibault Malbranche 2019-01-23 01:58:27 +01:00 committed by GitHub
parent 0fdd51de0e
commit 2846e27fcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View File

@ -1,9 +1,12 @@
buildscript {
ext.kotlin_version = '1.2.71'
//Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ReactNativeWebview_kotlinVersion']
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
//noinspection DifferentKotlinGradleVersion
@ -11,24 +14,23 @@ buildscript {
}
}
def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeWebview_' + name]
}
def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeWebview_' + name]).toInteger()
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
def DEFAULT_TARGET_SDK_VERSION = 27
def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
def DEFAULT_SUPPORT_LIB_VERSION = "28.0.0"
def getExtOrDefault(name, defaultValue) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue
}
android {
compileSdkVersion getExtOrDefault('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion getExtOrDefault('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
buildToolsVersion getExtOrDefault('buildToolsVersion')
defaultConfig {
minSdkVersion 16
targetSdkVersion getExtOrDefault('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
versionCode 1
versionName "1.0"
}
@ -117,7 +119,8 @@ repositories {
}
}
def support_version = getExtOrDefault('supportLibVersion', DEFAULT_SUPPORT_LIB_VERSION)
def support_version = getExtOrDefault('supportLibVersion')
def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
//noinspection GradleDynamicVersion

View File

@ -0,0 +1,5 @@
ReactNativeWebview_kotlinVersion=1.3.11
ReactNativeWebview_compileSdkVersion=28
ReactNativeWebview_buildToolsVersion=28.0.3
ReactNativeWebview_targetSdkVersion=28
ReactNativeWebview_supportLibVersion=28.0.0