From 53bc9ccf19882917c854c37506ce259e177f4175 Mon Sep 17 00:00:00 2001 From: Peter Storch Date: Wed, 25 Oct 2023 21:43:08 +0200 Subject: [PATCH] fix versionCodeOverride for nightly --- app/build.gradle.kts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ff38e93e..7c74e9eb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -6,7 +6,7 @@ plugins { id("de.mannodermaus.android-junit5") } -fun getVersionCode(): Int { +fun getGitVersionCode(): Int { return try { val stdout = ByteArrayOutputStream() exec { @@ -86,15 +86,16 @@ android { applicationVariants.all { if (name == "nightly") { - outputs.all { - this as com.android.build.gradle.internal.api.ApkVariantOutputImpl - versionCodeOverride = getVersionCode() - versionNameOverride = "${applicationId}_${versionCode}" + outputs.forEach { output -> + output as com.android.build.gradle.internal.api.ApkVariantOutputImpl + output.versionCodeOverride = getGitVersionCode() + output.versionNameOverride = "${applicationId}_${output.versionCode}" + output.outputFileName = "${applicationId}_${versionCode}.apk" } } - outputs.all { - this as com.android.build.gradle.internal.api.ApkVariantOutputImpl - outputFileName = "${applicationId}_${versionCode}.apk" + outputs.forEach { output -> + output as com.android.build.gradle.internal.api.ApkVariantOutputImpl + output.outputFileName = "${applicationId}_${output.versionCode}.apk" } }