diff options
| author | Albin <albin@mullvad.net> | 2023-11-10 11:25:46 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-11-10 11:25:46 +0100 |
| commit | c3482892cd7d8c26856c95c8a805ceab19e8d162 (patch) | |
| tree | e00f1007081bb875628190294fbfff834b0d0b89 | |
| parent | e29a55c585e346230a502afbe12c0b03e4275b3c (diff) | |
| parent | dc957ab8ba4fb577fd5bf182b195ae4e1c7b970c (diff) | |
| download | mullvadvpn-c3482892cd7d8c26856c95c8a805ceab19e8d162.tar.xz mullvadvpn-c3482892cd7d8c26856c95c8a805ceab19e8d162.zip | |
Merge branch 'add-version-code-check'
| -rw-r--r-- | android/app/build.gradle.kts | 12 | ||||
| -rw-r--r-- | android/buildSrc/src/main/kotlin/VerificationConstants.kt | 2 |
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 |
