From 0501e323428137e4ddaca4943c3072f1b211f60a Mon Sep 17 00:00:00 2001 From: Linh Pham Date: Mon, 7 Aug 2023 17:57:18 -0700 Subject: [PATCH] Use one version code for all apks (#503) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can move away from having separate version code for each build type now that we're publishing app bundle This change should also help resolve issues with AGP 8.1 upgrade --- .../slack/gradle/ApkVersioningPlugin.kt | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/slack-plugin/src/main/kotlin/slack/gradle/ApkVersioningPlugin.kt b/slack-plugin/src/main/kotlin/slack/gradle/ApkVersioningPlugin.kt index 214a72d51..221705a70 100644 --- a/slack-plugin/src/main/kotlin/slack/gradle/ApkVersioningPlugin.kt +++ b/slack-plugin/src/main/kotlin/slack/gradle/ApkVersioningPlugin.kt @@ -18,8 +18,6 @@ package slack.gradle import com.android.build.api.variant.ApplicationAndroidComponentsExtension -import com.android.build.api.variant.FilterConfiguration -import com.android.build.api.variant.VariantOutput import com.android.build.gradle.AppPlugin import java.util.Properties import org.gradle.api.DefaultTask @@ -47,11 +45,6 @@ import slack.gradle.util.setDisallowChanges @Suppress("unused") internal class ApkVersioningPlugin : Plugin { - private val VariantOutput.abiString: String? - get() { - return filters.find { it.filterType == FilterConfiguration.FilterType.ABI }?.identifier - } - @Suppress("LongMethod") override fun apply(project: Project) { project.plugins.withType(AppPlugin::class.java) { @@ -124,14 +117,7 @@ internal class ApkVersioningPlugin : Plugin { // Have to iterate outputs because of APK splits. variant.outputs.forEach { variantOutput -> variantOutput.versionName.setDisallowChanges(mappedVersionNameProvider) - - // Reuse the same task and just remap its value as needed - val mappedVersionCodeProvider = - versionCodeProvider.map { rawCode -> - @Suppress("MagicNumber") - ApkVersioning.VERSION_CODES.getValue(variantOutput.abiString) * 10000000 + rawCode - } - variantOutput.versionCode.setDisallowChanges(mappedVersionCodeProvider) + variantOutput.versionCode.setDisallowChanges(versionCodeProvider) } } } @@ -141,17 +127,6 @@ internal class ApkVersioningPlugin : Plugin { private object ApkVersioning { const val DEFAULT_VERSION_CODE: Int = 9999 - - // Override version code based on the ABI - // https://androidbycode.wordpress.com/2015/06/30/android-ndk-version-code-scheme-for-publishing-apks-per-architecture/ - val VERSION_CODES: Map = - mapOf( - null to 0, // Universal APK for CI - "arm64-v8a" to 3, - "armeabi-v7a" to 2, - "x86" to 8, - "x86_64" to 9 - ) } /**