diff --git a/build-logic/plugins/src/main/kotlin/com/wire/android/gradle/version/Versionizer.kt b/build-logic/plugins/src/main/kotlin/com/wire/android/gradle/version/Versionizer.kt index 5729fa366ec..c3da2ff0410 100644 --- a/build-logic/plugins/src/main/kotlin/com/wire/android/gradle/version/Versionizer.kt +++ b/build-logic/plugins/src/main/kotlin/com/wire/android/gradle/version/Versionizer.kt @@ -29,7 +29,21 @@ import java.time.LocalDateTime */ class Versionizer(private val localDateTime: LocalDateTime = LocalDateTime.now()) { - val versionCode = generateVersionCode() + // get version from app/version.txt otherwise use the current date + val versionCode = readFromInternalFile() ?: generateVersionCode() + + // get version from app/version.txt otherwise use the current date the file have the following format + // VersionCode: $$VERCODE$$\n + // the file is added by CI tp sync build version between store and fdroid + private fun readFromInternalFile(): Int? { + val file = java.io.File("app/version.txt") + if (file.exists()) { + val lines = file.readLines() + val versionCode = lines.find { it.startsWith("VersionCode:") }?.substringAfter(":")?.trim() + return versionCode?.toIntOrNull() + } + return null + } private fun generateVersionCode(): Int { return if (localDateTime <= V2_DATE_OFFSET) { diff --git a/build.gradle.kts b/build.gradle.kts index 4847526b138..f7e2eb8891d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,7 @@ buildscript { google() mavenCentral() maven(url = "https://oss.sonatype.org/content/repositories/snapshots") - maven(url ="https://plugins.gradle.org/m2/") + maven(url = "https://plugins.gradle.org/m2/") } dependencies { classpath(libs.hilt.gradlePlugin) @@ -32,7 +32,7 @@ buildscript { .lowercase() .contains("fdroid") - if (fdroidBuild) { + if (fdroidBuild) { println("Not including gms") } else { println("Including gms") @@ -46,7 +46,7 @@ allprojects { repositories { google() mavenCentral() - maven { url = java.net.URI("https://jitpack.io") } + maven(url = "https://jitpack.io") maven(url = "https://oss.sonatype.org/content/repositories/snapshots") } } diff --git a/gradle.properties b/gradle.properties index 679ba85d055..9201c2b69f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,3 +22,4 @@ kotlin.code.style=official # Support KMP Gradle Composite Builds - See https://youtrack.jetbrains.com/issue/KT-52172/ kotlin.mpp.import.enableKgpDependencyResolution=true +org.gradle.logging.level=QUIET