byteclaw/android/app/build.gradle.kts

82 lines
3.2 KiB
Kotlin

import java.util.Properties
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.paparazzi) // screenshot tests only (JVM, test source set)
}
// Release signing: values come from env (BYTECLAW_KEYSTORE_FILE/_PASSWORD, BYTECLAW_KEY_ALIAS/_PASSWORD)
// or from android/keystore.properties (storeFile, storePassword, keyAlias, keyPassword).
// keystore.properties and *.jks/*.keystore are gitignored. Without them the release APK stays unsigned.
val keystoreProps = Properties().apply {
val f = rootProject.file("keystore.properties")
if (f.isFile) f.inputStream().use { load(it) }
}
fun signingValue(env: String, prop: String): String? =
System.getenv(env)?.takeIf { it.isNotBlank() } ?: keystoreProps.getProperty(prop)?.takeIf { it.isNotBlank() }
val releaseStoreFile = signingValue("BYTECLAW_KEYSTORE_FILE", "storeFile")
val releaseStorePassword = signingValue("BYTECLAW_KEYSTORE_PASSWORD", "storePassword")
val releaseKeyAlias = signingValue("BYTECLAW_KEY_ALIAS", "keyAlias")
val releaseKeyPassword = signingValue("BYTECLAW_KEY_PASSWORD", "keyPassword")
val hasReleaseSigning = listOf(releaseStoreFile, releaseStorePassword, releaseKeyAlias, releaseKeyPassword).all { it != null }
android {
namespace = "dev.byteclaw.client"
compileSdk = 35
defaultConfig {
applicationId = "dev.byteclaw.client"
minSdk = 26
targetSdk = 35
versionCode = 5
versionName = "0.3.2"
}
signingConfigs {
if (hasReleaseSigning) {
create("release") {
storeFile = file(releaseStoreFile!!.replaceFirst(Regex("^~"), System.getProperty("user.home")))
storePassword = releaseStorePassword
keyAlias = releaseKeyAlias
keyPassword = releaseKeyPassword
enableV2Signing = true
enableV3Signing = true
}
}
}
buildTypes {
release {
if (hasReleaseSigning) signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions { jvmTarget = "17" }
buildFeatures { compose = true }
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.security.crypto)
implementation(platform(libs.compose.bom))
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.compose.material3)
implementation(libs.compose.material.icons)
implementation(libs.okhttp)
implementation(libs.kotlinx.serialization.json)
debugImplementation(libs.compose.ui.tooling)
testImplementation(libs.junit)
}