Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 173d582

Browse files
committed
Conditionally sign the release build for cases when there are no secrets (e.g. lint/debug builds)
1 parent c129dcc commit 173d582

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

build-logic/convention/src/main/kotlin/GravatarAndroidApplicationConventionPlugin.kt

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,29 @@ class GravatarAndroidApplicationConventionPlugin : Plugin<Project> {
4040
}
4141

4242
private fun ApplicationExtension.configureBuildTypes(project: Project) {
43+
val secretsProperties = project.property("secretsProperties") as java.util.Properties
44+
val secretsPath = project.property("secretsPath") as String
45+
val canSignRelease = secretsProperties.isNotEmpty()
46+
47+
if (!canSignRelease) {
48+
project.logger.warn("Release signing configuration skipped: no secrets properties found")
49+
}
50+
4351
signingConfigs {
44-
getByName("debug") {
52+
maybeCreate("debug").apply {
4553
storeFile = project.rootProject.file("debug.keystore")
4654
storePassword = "android"
4755
keyAlias = "androiddebugkey"
4856
keyPassword = "android"
4957
}
50-
create("release") {
51-
val secretsProperties = project.property("secretsProperties") as java.util.Properties
52-
val secretsPath = project.property("secretsPath") as String
53-
val storeFileName = secretsProperties.getProperty("uploadStoreFile") as String
54-
55-
storeFile = project.file("$secretsPath/$storeFileName")
56-
storePassword = secretsProperties.getProperty("uploadStorePassword")
57-
keyAlias = secretsProperties.getProperty("uploadKeyAlias")
58-
keyPassword = secretsProperties.getProperty("uploadKeyPassword")
58+
59+
if (canSignRelease) {
60+
maybeCreate("release").apply {
61+
storeFile = project.file("$secretsPath/${secretsProperties.getProperty("uploadStoreFile")}")
62+
storePassword = secretsProperties.getProperty("uploadStorePassword")
63+
keyAlias = secretsProperties.getProperty("uploadKeyAlias")
64+
keyPassword = secretsProperties.getProperty("uploadKeyPassword")
65+
}
5966
}
6067
}
6168

@@ -69,7 +76,10 @@ class GravatarAndroidApplicationConventionPlugin : Plugin<Project> {
6976
getDefaultProguardFile("proguard-android-optimize.txt"),
7077
"proguard-rules.pro",
7178
)
72-
signingConfig = signingConfigs.getByName("release")
79+
// Only set release signing config if it was created
80+
signingConfigs.findByName("release")?.let { releaseSigningConfig ->
81+
signingConfig = releaseSigningConfig
82+
}
7383
}
7484
}
7585
}

0 commit comments

Comments
 (0)