Files
AudioManagerClient/composeApp/build.gradle.kts
T
TapTap 9b105b3925
CI / build (push) Failing after 33s
build: target API 36 and sign Play upload bundles
- compileSdk/targetSdk 36: Google Play rejects new apps below API 36 since
  31 August 2026.
- Release signing from ANDROID_KEYSTORE_* environment variables or
  local.properties; unsigned when no upload key is configured.
- versionCode/versionName overridable via VERSION_CODE/VERSION_NAME.
- scripts/build-release-aab.sh builds and verifies a signed AAB.
- CI installs platform 36 until the CI image is rebuilt.
- Document the internal-testing upload flow.
2026-11-15 18:39:24 +00:00

171 lines
5.7 KiB
Kotlin

@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
import java.util.Properties
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("org.jetbrains.compose")
id("org.jetbrains.kotlin.plugin.compose")
id("com.android.application")
}
// Release signing and version numbers come from the environment in CI, or from
// local.properties for local release builds. Nothing secret is committed:
// local.properties is git-ignored. Without an upload key the release build
// still works, but the AAB is unsigned and cannot be uploaded to Play.
val localProperties = Properties().apply {
val file = rootProject.file("local.properties")
if (file.exists()) file.inputStream().use { load(it) }
}
fun signingValue(property: String, env: String): String? =
(System.getenv(env) ?: localProperties.getProperty(property))?.takeIf { it.isNotBlank() }
val uploadKeyStore = signingValue("UPLOAD_STORE_FILE", "ANDROID_KEYSTORE_PATH")?.let { rootProject.file(it) }
val uploadKeyStorePassword = signingValue("UPLOAD_STORE_PASSWORD", "ANDROID_KEYSTORE_PASSWORD")
val uploadKeyAlias = signingValue("UPLOAD_KEY_ALIAS", "ANDROID_KEY_ALIAS")
val uploadKeyPassword = signingValue("UPLOAD_KEY_PASSWORD", "ANDROID_KEY_PASSWORD")
val hasUploadKey = uploadKeyStore?.exists() == true &&
!uploadKeyStorePassword.isNullOrEmpty() &&
!uploadKeyAlias.isNullOrEmpty() &&
!uploadKeyPassword.isNullOrEmpty()
// Play requires a strictly increasing versionCode for every upload. CI can pass
// VERSION_CODE / VERSION_NAME (for example from the git tag).
val appVersionCode = (System.getenv("VERSION_CODE") ?: localProperties.getProperty("VERSION_CODE") ?: "1").toInt()
val appVersionName = System.getenv("VERSION_NAME")
?: localProperties.getProperty("VERSION_NAME")
?: "0.1.0"
kotlin {
androidTarget {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
jvm("desktop") {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
wasmJs {
outputModuleName.set("composeApp")
browser {
commonWebpackConfig {
outputFileName = "composeApp.js"
}
}
binaries.executable()
}
sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.ui)
implementation("io.ktor:ktor-client-core:3.1.2")
implementation("io.ktor:ktor-client-content-negotiation:3.1.2")
implementation("io.ktor:ktor-serialization-kotlinx-json:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2")
}
commonTest.dependencies {
implementation(kotlin("test"))
implementation("io.ktor:ktor-client-mock:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1")
}
androidMain.dependencies {
implementation("io.ktor:ktor-client-okhttp:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")
implementation("androidx.activity:activity-compose:1.10.1")
implementation("androidx.media3:media3-exoplayer:1.6.1")
implementation("androidx.media3:media3-common:1.6.1")
implementation("androidx.media3:media3-session:1.6.1")
}
val desktopMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation("io.ktor:ktor-client-cio:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.10.1")
implementation("com.googlecode.soundlibs:mp3spi:1.9.5.4")
}
}
val wasmJsMain by getting {
dependencies {
implementation("io.ktor:ktor-client-js:3.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-browser:0.3")
}
}
}
}
android {
namespace = "win.taptap.musicmanager.client"
// Google Play requires new apps and updates to target API 36 from
// 31 August 2026.
compileSdk = 36
defaultConfig {
applicationId = "win.taptap.musicmanager.client"
minSdk = 26
targetSdk = 36
versionCode = appVersionCode
versionName = appVersionName
}
signingConfigs {
if (hasUploadKey) {
create("release") {
storeFile = uploadKeyStore
storePassword = uploadKeyStorePassword
keyAlias = uploadKeyAlias
keyPassword = uploadKeyPassword
}
}
}
buildTypes {
release {
if (hasUploadKey) signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = false
isShrinkResources = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
compose.desktop {
application {
mainClass = "win.taptap.musicmanager.client.MainKt"
nativeDistributions {
targetFormats(TargetFormat.Deb, TargetFormat.Dmg, TargetFormat.Msi)
packageName = "AudioManager"
packageVersion = "1.0.0"
}
}
}