Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use one version code for all apks #503

Merged
merged 4 commits into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions slack-plugin/src/main/kotlin/slack/gradle/ApkVersioningPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,11 +45,6 @@ import slack.gradle.util.setDisallowChanges
@Suppress("unused")
internal class ApkVersioningPlugin : Plugin<Project> {

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) {
Expand Down Expand Up @@ -124,14 +117,7 @@ internal class ApkVersioningPlugin : Plugin<Project> {
// 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)
}
}
}
Expand All @@ -141,17 +127,6 @@ internal class ApkVersioningPlugin : Plugin<Project> {
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<String?, Int> =
mapOf(
null to 0, // Universal APK for CI
"arm64-v8a" to 3,
"armeabi-v7a" to 2,
"x86" to 8,
"x86_64" to 9
)
}

/**
Expand Down