From 1205a254787811ac8eabe8b14c65c6a1fc5bd6cf Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Tue, 17 Mar 2020 09:49:47 -0700 Subject: [PATCH] Fixed FxR Version Code (#2968) --- app/build.gradle | 11 +++++++++++ .../org/mozilla/vrbrowser/utils/StringUtils.java | 2 +- tools/gradle/versionCode.gradle | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3a005908d..61fef3d94 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -558,3 +558,14 @@ if (gradle.hasProperty('localProperties.dependencySubstitutions.geckoviewTopsrcd apply from: "${topsrcdir}/substitute-local-geckoview.gradle" } +// ------------------------------------------------------------------------------------------------- +// Dynamically set versionCode (See tools/build/versionCode.gradle +// ------------------------------------------------------------------------------------------------- + +android.applicationVariants.all { variant -> + if (gradle.hasProperty('userProperties.taskclusterBuild')) { + variant.outputs.each { output -> + output.versionCodeOverride = generatedVersionCode + } + } +} diff --git a/app/src/common/shared/org/mozilla/vrbrowser/utils/StringUtils.java b/app/src/common/shared/org/mozilla/vrbrowser/utils/StringUtils.java index 9991f3316..c69f96e89 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/utils/StringUtils.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/utils/StringUtils.java @@ -92,7 +92,7 @@ public static boolean contains(String[] aTarget, String aText) { * @return String The converted date in the format yyyy-MM-dd */ public static String versionCodeToDate(final @NonNull Context context, final int aVersionCode) { - String versionCode = Integer.toString(aVersionCode); + String versionCode = Integer.toString(aVersionCode - 100000000); String formatted; try { diff --git a/tools/gradle/versionCode.gradle b/tools/gradle/versionCode.gradle index a03b5c39f..2306f1c57 100644 --- a/tools/gradle/versionCode.gradle +++ b/tools/gradle/versionCode.gradle @@ -37,7 +37,9 @@ ext { // minute. def time = new SimpleDateFormat("HHmm").format(today) - generatedVersionCode = (year + day + time) as int + def baseNumber = (year + day + time) as int + + generatedVersionCode = 100000000 + baseNumber println("Generated versionCode: $generatedVersionCode") println()