Skip to content

Commit

Permalink
update build.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
saulhdev committed Jul 6, 2020
1 parent b9fd00f commit d9cf365
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import java.text.SimpleDateFormat
buildscript {
ext.kotlin_version = '1.3.72'
ext.version_plugin_kotlin = "1.3.31"
ext.enable_plugin_kotlin = true

ext.getGitHash = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (Exception ignored) {
return 'unknown'
}
}

repositories {
google()
jcenter()
Expand Down Expand Up @@ -39,6 +53,8 @@ android {
versionCode code

buildConfigField "boolean", "FEATURE_SETTINGS_SEARCH", "true"
buildConfigField "String", "BUILD_DATE", "\"${getBuildDate()}\""
buildConfigField "String", "GITHASH", "\"${getGitHash()}\""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -256,4 +272,13 @@ task copyRepoFiles(type: Copy) {
from rootProject.files(ROOT_TO_RAW_COPY_FILES)
into "res/raw"
rename { String fileName -> fileName.replace(fileName, fileName.toLowerCase()) }
}
}


@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection", "GroovyUnusedDeclaration"])
// Returns the build date in a RFC3339 compatible format. TZ is always converted to UTC
static String getBuildDate() {
final SimpleDateFormat RFC3339_LIKE = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
RFC3339_LIKE.setTimeZone(TimeZone.getTimeZone("UTC"))
return RFC3339_LIKE.format(new Date())
}

0 comments on commit d9cf365

Please sign in to comment.