[App] Move buildTimestamp to manifest to improve build performance.

This commit is contained in:
Kuba Szczodrzyński 2021-04-05 20:00:38 +02:00
parent ea2974bfae
commit 582e2059d8
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB
3 changed files with 13 additions and 2 deletions

View File

@ -18,8 +18,10 @@ android {
versionName release.versionName versionName release.versionName
buildConfigField "java.util.Map<String, String>", "GIT_INFO", gitInfoMap buildConfigField "java.util.Map<String, String>", "GIT_INFO", gitInfoMap
buildConfigField "long", "BUILD_TIMESTAMP", String.valueOf(System.currentTimeMillis())
buildConfigField "String", "VERSION_BASE", "\"${release.versionName}\"" buildConfigField "String", "VERSION_BASE", "\"${release.versionName}\""
manifestPlaceholders = [
buildTimestamp: String.valueOf(System.currentTimeMillis())
]
multiDexEnabled = true multiDexEnabled = true

View File

@ -29,6 +29,8 @@
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<meta-data android:name="buildTimestamp" android:value="${buildTimestamp}" />
<!-- __ __ _ _ _ _ _ <!-- __ __ _ _ _ _ _
| \/ | (_) /\ | | (_) (_) | | \/ | (_) /\ | | (_) (_) |
| \ / | __ _ _ _ __ / \ ___| |_ ___ ___| |_ _ _ | \ / | __ _ _ _ __ / \ ___| |_ ___ ___| |_ _ _

View File

@ -4,6 +4,7 @@
package pl.szczodrzynski.edziennik.utils.managers package pl.szczodrzynski.edziennik.utils.managers
import android.content.pm.PackageManager
import android.text.TextUtils import android.text.TextUtils
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -26,12 +27,18 @@ class BuildManager(val app: App) : CoroutineScope {
val buildFlavor = BuildConfig.FLAVOR val buildFlavor = BuildConfig.FLAVOR
val buildType = BuildConfig.BUILD_TYPE val buildType = BuildConfig.BUILD_TYPE
val buildTimestamp = BuildConfig.BUILD_TIMESTAMP
val isRelease = !BuildConfig.DEBUG val isRelease = !BuildConfig.DEBUG
val isDebug = BuildConfig.DEBUG val isDebug = BuildConfig.DEBUG
val isNightly = BuildConfig.VERSION_NAME.contains("nightly") val isNightly = BuildConfig.VERSION_NAME.contains("nightly")
val isDaily = BuildConfig.VERSION_NAME.contains("daily") val isDaily = BuildConfig.VERSION_NAME.contains("daily")
val buildTimestamp: Long
get() {
val info = app.packageManager.getApplicationInfo(app.packageName, PackageManager.GET_META_DATA)
val metadata = info.metaData
return metadata?.getFloat("buildTimestamp")?.toLong() ?: 0
}
val gitHash = BuildConfig.GIT_INFO["hash"] val gitHash = BuildConfig.GIT_INFO["hash"]
val gitVersion = BuildConfig.GIT_INFO["version"] val gitVersion = BuildConfig.GIT_INFO["version"]
val gitBranch = BuildConfig.GIT_INFO["branch"] val gitBranch = BuildConfig.GIT_INFO["branch"]