Skip to content

Commit 54fa2dc

Browse files
committed
Fix Gradle null-handling in version code/name and signingConfigs DSL
1 parent 6655df3 commit 54fa2dc

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

web/android/app/build.gradle

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@ def releaseKeyAlias = keystoreProperties['keyAlias'] ?: System.getenv('SPENDWISE
2020
def releaseKeyPassword = keystoreProperties['keyPassword'] ?: System.getenv('SPENDWISE_KEY_PASSWORD')
2121
def hasReleaseSigning = releaseStoreFile && releaseStorePassword && releaseKeyAlias && releaseKeyPassword
2222

23+
def envVersionCode = System.getenv('SPENDWISE_VERSION_CODE')
24+
def appVersionCode = (envVersionCode != null && !envVersionCode.isEmpty()) ? envVersionCode.toInteger() : 1
25+
def envVersionName = System.getenv('SPENDWISE_VERSION_NAME')
26+
def appVersionName = (envVersionName != null && !envVersionName.isEmpty()) ? envVersionName : '1.0.0'
27+
2328
android {
2429
namespace = "com.spendwise.app"
2530
compileSdk = rootProject.ext.compileSdkVersion
2631
defaultConfig {
2732
applicationId "com.spendwise.app"
2833
minSdkVersion rootProject.ext.minSdkVersion
2934
targetSdkVersion rootProject.ext.targetSdkVersion
30-
versionCode (System.getenv('SPENDWISE_VERSION_CODE') ?: '1') as Integer
31-
versionName System.getenv('SPENDWISE_VERSION_NAME') ?: '1.0.0'
35+
versionCode appVersionCode
36+
versionName appVersionName
3237
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3338
aaptOptions {
3439
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
@@ -37,8 +42,8 @@ android {
3742
}
3843
}
3944
signingConfigs {
40-
if (hasReleaseSigning) {
41-
release {
45+
release {
46+
if (hasReleaseSigning) {
4247
storeFile file(releaseStoreFile)
4348
storePassword releaseStorePassword
4449
keyAlias releaseKeyAlias

0 commit comments

Comments
 (0)