Files
AudioManagerClient/composeApp/build.gradle.kts
T
TapTap 8e737fae2e
CI / build (push) Successful in 3m59s
CI / play (push) Successful in 3m27s
fix: mirror a live service timeline after the UI is recreated
The media service can keep playing after the task is swiped. A new UI now
adopts its queue, index and position instead of showing a stale paused state.
Notification artwork also uses cached offline covers. Version 0.4.1.
2026-11-19 16:58:20 +00:00

189 lines
6.6 KiB
Kotlin

@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
import java.util.Properties
import com.github.triplet.gradle.androidpublisher.ReleaseStatus
import com.github.triplet.gradle.androidpublisher.ResolutionStrategy
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")
id("com.github.triplet.play")
}
// 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.4.1"
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 {
// The package name shown in Play Console. It is permanent after the
// first upload. The Kotlin package/namespace stays as-is: the manifest
// and generated R/BuildConfig classes use the namespace, Play uses the
// application id.
applicationId = "win.tap_tap.audiomanager.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}"
}
}
}
play {
// Upload the release AAB to the internal testing track. Credentials are
// never committed: CI sets ANDROID_PUBLISHER_CREDENTIALS, and local runs
// can use the same variable or PLAY_SERVICE_ACCOUNT_JSON in local.properties.
track.set("internal")
defaultToAppBundles.set(true)
releaseStatus.set(ReleaseStatus.COMPLETED)
// Ask Play for the next free version code instead of hand-bumping it.
resolutionStrategy.set(ResolutionStrategy.AUTO)
}
compose.desktop {
application {
mainClass = "win.taptap.musicmanager.client.MainKt"
nativeDistributions {
targetFormats(TargetFormat.Deb, TargetFormat.Dmg, TargetFormat.Msi)
packageName = "AudioManager"
packageVersion = "1.0.0"
}
}
}