summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--android/app/build.gradle.kts12
-rw-r--r--android/buildSrc/src/main/kotlin/VerificationConstants.kt2
2 files changed, 14 insertions, 0 deletions
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index f0b0a2f1a0..df86dd3507 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -228,6 +228,7 @@ android {
}
project.tasks.preBuild.dependsOn("ensureJniDirectoryExist")
+ project.tasks.preBuild.dependsOn("ensureValidVersionCode")
}
androidComponents {
@@ -265,6 +266,17 @@ tasks.register("ensureJniDirectoryExist") {
}
}
+// This is a safety net to avoid generating too big version codes, since that could potentially be
+// hard and inconvenient to recover from.
+tasks.register("ensureValidVersionCode") {
+ doLast {
+ val versionCode = project.android.defaultConfig.versionCode!!
+ if (versionCode >= MAX_ALLOWED_VERSION_CODE) {
+ throw GradleException("Bad version code: $versionCode")
+ }
+ }
+}
+
tasks.create("printVersion") {
doLast {
println("versionCode=${project.android.defaultConfig.versionCode}")
diff --git a/android/buildSrc/src/main/kotlin/VerificationConstants.kt b/android/buildSrc/src/main/kotlin/VerificationConstants.kt
new file mode 100644
index 0000000000..33422a0623
--- /dev/null
+++ b/android/buildSrc/src/main/kotlin/VerificationConstants.kt
@@ -0,0 +1,2 @@
+// This value represent a version code that would be generated from and after year 2030.
+const val MAX_ALLOWED_VERSION_CODE = 30000000