diff options
| author | Albin <albin@mullvad.net> | 2023-11-10 10:35:52 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-11-10 10:45:39 +0100 |
| commit | dc957ab8ba4fb577fd5bf182b195ae4e1c7b970c (patch) | |
| tree | e00f1007081bb875628190294fbfff834b0d0b89 /android | |
| parent | e29a55c585e346230a502afbe12c0b03e4275b3c (diff) | |
| download | mullvadvpn-dc957ab8ba4fb577fd5bf182b195ae4e1c7b970c.tar.xz mullvadvpn-dc957ab8ba4fb577fd5bf182b195ae4e1c7b970c.zip | |
Add version code check
The check will fail unless the version code is less than 30000000.
This means that all version codes up until the year 2030 are valid.
The check runs before the preBuild task.
Diffstat (limited to 'android')
| -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 |
