From 55ee04aab1ae8653e97fa05a8325300f251931c4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Sep 2025 11:32:27 +0200 Subject: [PATCH 1/4] Release script: read the build tool version from Versions.kt --- plugins/src/main/kotlin/Versions.kt | 5 +++-- tools/release/release.sh | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/src/main/kotlin/Versions.kt b/plugins/src/main/kotlin/Versions.kt index f02b468b6e..4a26320bb8 100644 --- a/plugins/src/main/kotlin/Versions.kt +++ b/plugins/src/main/kotlin/Versions.kt @@ -38,9 +38,10 @@ object Versions { const val VERSION_CODE = (2000 + versionYear) * 10_000 + versionMonth * 100 + versionReleaseNumber val VERSION_NAME = "$versionYear.${versionMonth.toString().padStart(2, '0')}.$versionReleaseNumber" - // When updating COMPILE_SDK, please do not forget to update the value for `buildToolsVersion` - // in the file `tools/release/release.sh` + // When updating COMPILE_SDK, please also update BUILD_TOOLS_VERSION const val COMPILE_SDK = 36 + @Suppress("unused") + private const val BUILD_TOOLS_VERSION = "36.0.0" const val TARGET_SDK = 36 // When updating the `minSdk`, make sure to update the value of `minSdkVersion` in the file `tools/release/release.sh` diff --git a/tools/release/release.sh b/tools/release/release.sh index 30d4cea205..6727ebb309 100755 --- a/tools/release/release.sh +++ b/tools/release/release.sh @@ -64,7 +64,8 @@ fi # Read minSdkVersion from file plugins/src/main/kotlin/Versions.kt minSdkVersion=$(grep "MIN_SDK_FOSS =" ./plugins/src/main/kotlin/Versions.kt |cut -d '=' -f 2 |xargs) -buildToolsVersion="36.0.0" +# Read buildToolsVersion from file plugins/src/main/kotlin/Versions.kt +buildToolsVersion=$(grep "BUILD_TOOLS_VERSION =" ./plugins/src/main/kotlin/Versions.kt |cut -d '=' -f 2 |xargs) buildToolsPath="${androidHome}/build-tools/${buildToolsVersion}" if [[ ! -d ${buildToolsPath} ]]; then From 724086cbb10c3f3a3d02aec49f6a41df9dc4f803 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Sep 2025 11:34:26 +0200 Subject: [PATCH 2/4] Remove obsolete comment. The release script now reads the value from Versions.kt --- plugins/src/main/kotlin/Versions.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/src/main/kotlin/Versions.kt b/plugins/src/main/kotlin/Versions.kt index 4a26320bb8..d180867444 100644 --- a/plugins/src/main/kotlin/Versions.kt +++ b/plugins/src/main/kotlin/Versions.kt @@ -44,7 +44,6 @@ object Versions { private const val BUILD_TOOLS_VERSION = "36.0.0" const val TARGET_SDK = 36 - // When updating the `minSdk`, make sure to update the value of `minSdkVersion` in the file `tools/release/release.sh` private const val MIN_SDK_FOSS = 24 private const val MIN_SDK_ENTERPRISE = 33 val minSdk = if (isEnterpriseBuild) MIN_SDK_ENTERPRISE else MIN_SDK_FOSS From 61f1a04867082643c7d3270966a07c6d618a6878 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Sep 2025 11:46:02 +0200 Subject: [PATCH 3/4] Add static checks --- plugins/src/main/kotlin/Versions.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/src/main/kotlin/Versions.kt b/plugins/src/main/kotlin/Versions.kt index d180867444..dd312f9faa 100644 --- a/plugins/src/main/kotlin/Versions.kt +++ b/plugins/src/main/kotlin/Versions.kt @@ -40,6 +40,7 @@ object Versions { // When updating COMPILE_SDK, please also update BUILD_TOOLS_VERSION const val COMPILE_SDK = 36 + @Suppress("unused") private const val BUILD_TOOLS_VERSION = "36.0.0" const val TARGET_SDK = 36 @@ -51,4 +52,11 @@ object Versions { private const val JAVA_VERSION = 21 val javaVersion: JavaVersion = JavaVersion.toVersion(JAVA_VERSION) val javaLanguageVersion: JavaLanguageVersion = JavaLanguageVersion.of(JAVA_VERSION) + + // Perform some checks on the values to avoid releasing with bad values + init { + require(versionMonth in 1..12) { "versionMonth must be in [1,12]" } + require(versionReleaseNumber in 0..99) { "versionReleaseNumber must be in [0,99]" } + require(BUILD_TOOLS_VERSION.startsWith(COMPILE_SDK.toString())) { "When updating COMPILE_SDK, please also update BUILD_TOOLS_VERSION" } + } } From 937d23b6ef0c5ef85ba7df310e4f1b607365f48e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 10 Sep 2025 11:58:38 +0200 Subject: [PATCH 4/4] Document Versions.kt --- plugins/src/main/kotlin/Versions.kt | 53 ++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/plugins/src/main/kotlin/Versions.kt b/plugins/src/main/kotlin/Versions.kt index dd312f9faa..14307ae741 100644 --- a/plugins/src/main/kotlin/Versions.kt +++ b/plugins/src/main/kotlin/Versions.kt @@ -13,9 +13,9 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion * Max versionCode allowed by the PlayStore (for information): * 2_100_000_000 * - * Also note that the versionCode is multiplied by 10 in app/build.gradle.kts#L168: + * Also note that the versionCode is multiplied by 10 in app/build.gradle.kts: * ``` - * output.versionCode.set((output.versionCode.get() ?: 0) * 10 + abiCode)) + * output.versionCode.set((output.versionCode.orNull ?: 0) * 10 + abiCode) * ``` * We are using a CalVer-like approach to version the application. The version code is calculated as follows: * - 2 digits for the year @@ -28,28 +28,73 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion * - the version code: 20250100a (202_501_00a) where `a` stands for the architecture code */ +/** + * Year of the version on 2 digits. + * Do not update this value. it is updated by the release script. + */ private const val versionYear = 25 + +/** + * Month of the version on 2 digits. Value must be in [1,12]. + * Do not update this value. it is updated by the release script. + */ private const val versionMonth = 9 -// Note: must be in [0,99] +/** + * Release number in the month. Value must be in [0,99]. + * Do not update this value. it is updated by the release script. + */ private const val versionReleaseNumber = 1 object Versions { + /** + * Base version code that will be set in the Android Manifest. + * The value will be modified at build time to add the ABI code when APK are build. + * AAB will have a ABI code of 0. + * See comment above for the calculation method. + */ const val VERSION_CODE = (2000 + versionYear) * 10_000 + versionMonth * 100 + versionReleaseNumber val VERSION_NAME = "$versionYear.${versionMonth.toString().padStart(2, '0')}.$versionReleaseNumber" - // When updating COMPILE_SDK, please also update BUILD_TOOLS_VERSION + /** + * Compile SDK version. Must be updated when a new Android version is released. + * When updating COMPILE_SDK, please also update BUILD_TOOLS_VERSION. + */ const val COMPILE_SDK = 36 + /** + * Build tools version. Must be kept in sync with COMPILE_SDK. + * The value is used by the release script. + */ @Suppress("unused") private const val BUILD_TOOLS_VERSION = "36.0.0" + + /** + * Target SDK version. Should be kept up to date with COMPILE_SDK. + */ const val TARGET_SDK = 36 + /** + * Minimum SDK version for FOSS builds. + */ private const val MIN_SDK_FOSS = 24 + + /** + * Minimum SDK version for Enterprise builds. + */ private const val MIN_SDK_ENTERPRISE = 33 + + /** + * minSdkVersion that will be set in the Android Manifest. + */ val minSdk = if (isEnterpriseBuild) MIN_SDK_ENTERPRISE else MIN_SDK_FOSS + /** + * Java version used for compilation. + * Update this value when you want to use a newer Java version. + */ private const val JAVA_VERSION = 21 + val javaVersion: JavaVersion = JavaVersion.toVersion(JAVA_VERSION) val javaLanguageVersion: JavaLanguageVersion = JavaLanguageVersion.of(JAVA_VERSION)