keystore added
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user