From 105a6a118b3b8e73e5b1e8c264e80987654904d7 Mon Sep 17 00:00:00 2001 From: YuutaW <17158086+Trumeet@users.noreply.github.com> Date: Sun, 24 Feb 2019 13:59:00 -0800 Subject: feat(app): read version from VCS Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com> --- build.gradle | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle index 5ec9780..17b7709 100644 --- a/build.gradle +++ b/build.gradle @@ -28,3 +28,19 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir } + +def gitCommitCount = 'git rev-list --count HEAD'.execute([], project.rootDir).text.trim() +def version = "0.${gitCommitCount}" + +ext { + versionCode = Integer.parseInt("${gitCommitCount}") + versionName = "${version}" +} + +task exportVersion(type: Exec) { + commandLine 'sh' + doLast { + file("$projectDir/version.txt").text = """$version""" + file("$projectDir/version_code.txt").text = """${gitCommitCount}""" + } +} \ No newline at end of file -- cgit v1.2.3