diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5cfaf0b..6c2271f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -47,32 +47,14 @@ android { } // --- Signing --- - // v0.3.6.3: Fail fast (at config time) with an actionable error - // when keystore/release.jks is missing, rather than silently - // letting packageRelease die later with the cryptic "SigningConfig - // release is missing required property storeFile". CI (see - // .gitea/workflows/release.yml) already mints the keystore before - // assembleRelease (since v0.3.6.2), so this branch never fires on - // a release runner — only on a fresh local clone. + // The release signing config is declared even when the keystore is absent; + // the existence check is deferred to assembleRelease execution time so that + // assembleDebug (which doesn't need the keystore) runs cleanly on a fresh + // clone. CI always mints the keystore before calling assembleRelease, so + // this branch never fires in the normal workflow. signingConfigs { create("release") { - val keystoreFilePath = rootProject.file("keystore/release.jks") - if (!keystoreFilePath.exists()) { - throw GradleException( - "Missing ${keystoreFilePath.absolutePath}.\n" + - "Generate the dev keystore documented in " + - "keystore/README.md:\n" + - " keytool -genkey -noprompt -v \\\n" + - " -keystore keystore/release.jks \\\n" + - " -keyalg RSA -keysize 2048 -validity 10000 \\\n" + - " -alias incido \\\n" + - " -storepass incido_dev_keystore \\\n" + - " -keypass incido_dev_keystore \\\n" + - " -dname \"CN=Incido Dev, OU=Local, O=Incido, " + - "L=Local, ST=Local, C=NZ\"" - ) - } - storeFile = keystoreFilePath + storeFile = rootProject.file("keystore/release.jks") storePassword = "incido_dev_keystore" keyAlias = "incido" keyPassword = "incido_dev_keystore" @@ -89,6 +71,32 @@ android { } } + // Fail fast with an actionable message only when assembleRelease actually + // runs and the keystore is missing — not during project configuration. + tasks.register("validateReleaseKeystore") { + group = "build" + description = "Validates that keystore/release.jks exists before assembleRelease runs" + onlyIf { + val f = rootProject.file("keystore/release.jks") + if (!f.exists()) { + throw GradleException( + "Missing ${f.absolutePath}.\n" + + "Generate the dev keystore documented in keystore/README.md:\n" + + " keytool -genkey -noprompt -v \\\n" + + " -keystore keystore/release.jks \\\n" + + " -keyalg RSA -keysize 2048 -validity 10000 \\\n" + + " -alias incido \\\n" + + " -storepass incido_dev_keystore \\\n" + + " -keypass incido_dev_keystore \\\n" + + " -dname \"CN=Incido Dev, OU=Local, O=Incido, " + + "L=Local, ST=Local, C=NZ\"" + ) + } + true + } + } + tasks.named("assembleRelease") { dependsOn("validateReleaseKeystore") } + buildFeatures { compose = true }