diff options
| author | Albin <albin@mullvad.net> | 2025-05-24 13:06:17 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2025-05-24 14:10:09 +0200 |
| commit | c9d24eb5e4d4adee854c098ca74d75ef0dc85ca3 (patch) | |
| tree | a68b589404984e4b625728fdc00f00f1655c3058 /android/buildSrc/src | |
| parent | 41fda5da5cd1b1e04e4cb3cab4ac63eb2423a236 (diff) | |
| download | mullvadvpn-c9d24eb5e4d4adee854c098ca74d75ef0dc85ca3.tar.xz mullvadvpn-c9d24eb5e4d4adee854c098ca74d75ef0dc85ca3.zip | |
Fix version code safeguard
Moving the version code safeguard in order to make it
configuration cache compliant.
Diffstat (limited to 'android/buildSrc/src')
| -rw-r--r-- | android/buildSrc/src/main/kotlin/Utils.kt | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/android/buildSrc/src/main/kotlin/Utils.kt b/android/buildSrc/src/main/kotlin/Utils.kt index d939363827..f9f9a7528c 100644 --- a/android/buildSrc/src/main/kotlin/Utils.kt +++ b/android/buildSrc/src/main/kotlin/Utils.kt @@ -1,4 +1,3 @@ -import java.util.* import org.gradle.api.Project // This is a hack and will not work correctly under all scenarios. @@ -18,8 +17,17 @@ fun Project.isDevBuild(): Boolean { return versionName.contains("-dev-") } -fun Project.generateVersionCode(): Int = - getIntPropertyOrNull("mullvad.app.config.override.versionCode") ?: execVersionCodeCargoCommand() +fun Project.generateVersionCode(): Int { + val versionCode = + getIntPropertyOrNull("mullvad.app.config.override.versionCode") + ?: execVersionCodeCargoCommand() + // This is a safety net to avoid generating too big version codes, since that could potentially + // be hard and inconvenient to recover from. + require(versionCode <= MAX_ALLOWED_VERSION_CODE) { + "versionCode ($versionCode) must be <= $MAX_ALLOWED_VERSION_CODE" + } + return versionCode +} fun Project.generateVersionName(): String = getStringPropertyOrNull("mullvad.app.config.override.versionName") |
