Allow cdvMinSdkVersion and cdvVersionCode to be set to ints (instead of just strings)

This commit is contained in:
Andrew Grieve 2015-01-30 11:42:56 -05:00
parent e3dd6d8c88
commit bf327f3916

View File

@ -110,7 +110,11 @@ if (ext.cdvCompileSdkVersion == null) {
if (ext.cdvBuildToolsVersion == null) { if (ext.cdvBuildToolsVersion == null) {
ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools() ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
} }
// Cast to appropriate types.
ext.cdvBuildMultipleApks = !!cdvBuildMultipleApks; ext.cdvBuildMultipleApks = !!cdvBuildMultipleApks;
ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : Integer.parseInt('' + cdvMinSdkVersion)
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)
def computeBuildTargetName(debugBuild) { def computeBuildTargetName(debugBuild) {
def ret = 'assemble' def ret = 'assemble'
@ -163,13 +167,10 @@ android {
} }
} }
def versionCodeOverride = cdvVersionCode ? Integer.parseInt(cdvVersionCode) : null
def minSdkVersionOverride = cdvMinSdkVersion ? Integer.parseInt(cdvMinSdkVersion) : null
defaultConfig { defaultConfig {
versionCode versionCodeOverride ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0") versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")
if (minSdkVersionOverride != null) { if (cdvMinSdkVersion != null) {
minSdkVersion minSdkVersionOverride minSdkVersion cdvMinSdkVersion
} }
} }
@ -179,13 +180,13 @@ android {
if (Boolean.valueOf(cdvBuildMultipleApks)) { if (Boolean.valueOf(cdvBuildMultipleApks)) {
productFlavors { productFlavors {
armv7 { armv7 {
versionCode versionCodeOverride ?: defaultConfig.versionCode + 2 versionCode cdvVersionCode ?: defaultConfig.versionCode + 2
ndk { ndk {
abiFilters "armeabi-v7a", "" abiFilters "armeabi-v7a", ""
} }
} }
x86 { x86 {
versionCode versionCodeOverride ?: defaultConfig.versionCode + 4 versionCode cdvVersionCode ?: defaultConfig.versionCode + 4
ndk { ndk {
abiFilters "x86", "" abiFilters "x86", ""
} }
@ -196,8 +197,8 @@ android {
} }
} }
} }
} else if (!versionCodeOverride) { } else if (!cdvVersionCode) {
def minSdkVersion = minSdkVersionOverride ?: privateHelpers.extractIntFromManifest("minSdkVersion") def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
// Vary versionCode by the two most common API levels: // Vary versionCode by the two most common API levels:
// 14 is ICS, which is the lowest API level for many apps. // 14 is ICS, which is the lowest API level for many apps.
// 20 is Lollipop, which is the lowest API level for the updatable system webview. // 20 is Lollipop, which is the lowest API level for the updatable system webview.