forked from Tadrisino/MathApp_frontend
Android: reproducible signed build (keystore and Bazaar RSA key read from outside the repo), Gradle wrapper, build-apk.sh
First time the project has been built: debug and release both produce an APK. Release refuses to build without keystore or RSA key. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,25 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
}
|
||||
|
||||
// تنظیماتِ حساس (keystore و کلیدِ RSAِ بازار) در ریپو نیستند. از فایلی بیرون از ریپو خوانده میشوند:
|
||||
// $TADRISINO_ANDROID_CONFIG یا ~/.tadrisino/android.properties
|
||||
// کلیدها: storeFile, storePassword, keyAlias, keyPassword, bazaarRsaKey. شرحِ کامل: README.md.
|
||||
val configFile = File(System.getenv("TADRISINO_ANDROID_CONFIG") ?: "${System.getProperty("user.home")}/.tadrisino/android.properties")
|
||||
val secrets = Properties().apply { if (configFile.exists()) configFile.inputStream().use { load(it) } }
|
||||
// فقط وقتی build از نوعِ release است الزامی است؛ debug بدونِ آن هم ساخته میشود.
|
||||
val wantsRelease = gradle.startParameter.taskNames.any { it.contains("release", ignoreCase = true) }
|
||||
fun secret(name: String): String {
|
||||
val v = secrets.getProperty(name)?.trim().orEmpty()
|
||||
if (wantsRelease && v.isEmpty()) {
|
||||
throw GradleException("build نوعِ release «$name» را لازم دارد. در ${configFile.path} نیست یا خالی است (README.md ← «تنظیماتِ بیرون از ریپو»).")
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
android {
|
||||
// ⚠️ اسمِ پکیج باید همانی باشد که در پیشخانِ بازار ثبت است. com.tadrisino.app را بازار
|
||||
// برای حسابِ شرکت «Product is not found» جواب داد (یعنی هست)، ولی سنیور تأیید نکرده
|
||||
@@ -21,7 +38,20 @@ android {
|
||||
buildConfigField("String", "WEB_URL", "\"https://math.tadrisino2.ir/\"")
|
||||
// کلیدِ RSAِ عمومیِ اپ از پیشخانِ بازار (بخشِ «پرداخت درونبرنامهای»). کلیدِ عمومی
|
||||
// است و در اپ مینشیند؛ رمز نیست. تا پر نشود، اپ خرید را شروع نمیکند.
|
||||
buildConfigField("String", "BAZAAR_RSA_KEY", "\"\"")
|
||||
// از فایلِ بیرون از ریپو؛ برای build نوعِ release خالی بودنش خطا میدهد (نه اپِ بیخرید).
|
||||
buildConfigField("String", "BAZAAR_RSA_KEY", "\"${secret("bazaarRsaKey")}\"")
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
// release بدونِ keystore ساخته نمیشود؛ هرگز بیصدا با کلیدِ debug امضا نمیشود.
|
||||
if (wantsRelease) {
|
||||
storeFile = file(secret("storeFile"))
|
||||
storePassword = secret("storePassword")
|
||||
keyAlias = secret("keyAlias")
|
||||
keyPassword = secret("keyPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
@@ -31,6 +61,7 @@ android {
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user