From 97fa94592e532a74ac1327f771931f991c289bd3 Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Wed, 13 Mar 2019 13:10:36 +0100 Subject: [PATCH] get timestamp for versioncode from last git commmit This makes the versioncode for an apk reproducible. Building the same commit/code will produce an apk with the same VC. Signed-off-by: Marcus Hoffmann --- app/build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 570cf611..f455d970 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,9 +15,14 @@ def versionMajor = 0 def versionMinor = 1 def versionPatch = 0 +def getGitTimestamp() { + def cmd = 'git show -s --format=%ct' + return cmd.execute().text.trim() as Long +} + def generateVersionCodeFromTimestamp() { // It's unix timestamp divided by 10: It's incremented by one every 10 seconds. - return (System.currentTimeMillis() / 1_000 / 10).toInteger() + return (getGitTimestamp() / 10).toInteger() } def generateVersionCodeFromVersionName() {