keystore added

This commit is contained in:
Hadrian Burkhardt
2026-05-10 21:18:29 +02:00
parent 7bfffd6b82
commit 5bfc769121
3 changed files with 62 additions and 0 deletions
+3
View File
@@ -9,6 +9,9 @@ build/
# Local machine config # Local machine config
local.properties local.properties
keystore.properties
*.jks
*.keystore
# OS files # OS files
.DS_Store .DS_Store
+59
View File
@@ -1,9 +1,51 @@
import java.util.Properties
plugins { plugins {
id("com.android.application") id("com.android.application")
id("com.google.devtools.ksp") id("com.google.devtools.ksp")
id("org.jetbrains.kotlin.plugin.compose") id("org.jetbrains.kotlin.plugin.compose")
} }
val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties().apply {
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.inputStream().use(::load)
}
}
fun signingValue(propertyName: String, envName: String): String? {
return (keystoreProperties[propertyName] as? String)
?.takeIf { it.isNotBlank() }
?: System.getenv(envName)?.takeIf { it.isNotBlank() }
}
val releaseStoreFile = signingValue("storeFile", "RELEASE_STORE_FILE")
val releaseStorePassword = signingValue("storePassword", "RELEASE_STORE_PASSWORD")
val releaseKeyAlias = signingValue("keyAlias", "RELEASE_KEY_ALIAS")
val releaseKeyPassword = signingValue("keyPassword", "RELEASE_KEY_PASSWORD")
val hasReleaseSigning = listOf(
releaseStoreFile,
releaseStorePassword,
releaseKeyAlias,
releaseKeyPassword
).all { !it.isNullOrBlank() }
gradle.taskGraph.whenReady {
val releaseBundleRequested = allTasks.any {
it.path == ":app:bundleRelease" || it.name == "bundleRelease"
}
val releaseApkRequested = allTasks.any {
it.path == ":app:assembleRelease" || it.name == "assembleRelease"
}
if ((releaseBundleRequested || releaseApkRequested) && !hasReleaseSigning) {
throw GradleException(
"Release signing is not configured. Fill storePassword, keyAlias, and keyPassword " +
"in keystore.properties, or set RELEASE_STORE_FILE, RELEASE_STORE_PASSWORD, " +
"RELEASE_KEY_ALIAS, and RELEASE_KEY_PASSWORD."
)
}
}
android { android {
namespace = "de.softwareapp_hb.privateqrscanner" namespace = "de.softwareapp_hb.privateqrscanner"
compileSdk = 36 compileSdk = 36
@@ -22,9 +64,26 @@ android {
} }
} }
signingConfigs {
if (hasReleaseSigning) {
create("release") {
storeFile = file(releaseStoreFile!!)
storePassword = releaseStorePassword
keyAlias = releaseKeyAlias
keyPassword = releaseKeyPassword
}
}
}
buildTypes { buildTypes {
release { release {
isMinifyEnabled = true isMinifyEnabled = true
if (hasReleaseSigning) {
signingConfig = signingConfigs.getByName("release")
}
ndk {
debugSymbolLevel = "SYMBOL_TABLE"
}
proguardFiles( proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro" "proguard-rules.pro"
Vendored Regular → Executable
View File