mirror of
https://github.com/dzeiocom/OpenHealth.git
synced 2025-07-01 09:09:18 +00:00
feat: Support for minified/optimized builds
This commit is contained in:
@ -20,6 +20,25 @@ plugins {
|
||||
kotlin("kapt")
|
||||
}
|
||||
|
||||
// from: https://discuss.kotlinlang.org/t/use-git-hash-as-version-number-in-build-gradle-kts/19818/8
|
||||
fun String.runCommand(
|
||||
workingDir: File = File("."),
|
||||
timeoutAmount: Long = 60,
|
||||
timeoutUnit: TimeUnit = TimeUnit.SECONDS
|
||||
): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
|
||||
.directory(workingDir)
|
||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||
.start()
|
||||
.apply { waitFor(timeoutAmount, timeoutUnit) }
|
||||
.run {
|
||||
val error = errorStream.bufferedReader().readText().trim()
|
||||
if (error.isNotEmpty()) {
|
||||
return@run ""
|
||||
}
|
||||
inputStream.bufferedReader().readText().trim()
|
||||
}
|
||||
|
||||
// The application ID
|
||||
val appID = "com.dzeio.openhealth"
|
||||
|
||||
@ -32,6 +51,14 @@ val sdkMin = 21
|
||||
// target SDK version
|
||||
val sdkTarget = 33
|
||||
|
||||
val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir)
|
||||
var tag = "git tag -l --points-at HEAD".runCommand(workingDir = rootDir)
|
||||
if (tag == "") {
|
||||
tag = "not tagged"
|
||||
}
|
||||
val commitId = "git rev-parse HEAD".runCommand(workingDir = rootDir)
|
||||
.subSequence(0, 7)
|
||||
|
||||
android {
|
||||
|
||||
signingConfigs {
|
||||
@ -83,28 +110,29 @@ android {
|
||||
"new String[]{\"" + locales.joinToString("\",\"") + "\"}"
|
||||
)
|
||||
resourceConfigurations += locales
|
||||
|
||||
buildConfigField("String", "BRANCH", "\"$branch\"")
|
||||
buildConfigField("String", "TAG", "\"$tag\"")
|
||||
buildConfigField("String", "COMMIT", "\"$commitId\"")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
getByName("release") {
|
||||
// Slimmer version
|
||||
isMinifyEnabled = false
|
||||
isShrinkResources = false
|
||||
isDebuggable = true
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
isDebuggable = false
|
||||
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
|
||||
getByName("debug") {
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
applicationIdSuffix = ".dev"
|
||||
versionNameSuffix = "-dev"
|
||||
isDebuggable = true
|
||||
|
Reference in New Issue
Block a user