mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-30 05:47:57 +01:00
Change foss variant application id suffix to '.foss' and more (#1831)
- Remove `BuildConfig.PREVIEW` - Rename `BuildConfig.INCLUDE_ANALYTICS` -> `BuildConfig.ANALYTICS_INCLUDED` - Rename `BuildConfig.INCLUDE_UPDATER` -> `BuildConfig.UPDATER_ENABLED` - Rename build property `with-analytics` -> `include-analytics` - Rename build property `with-updater` -> `enable-updater` - Add build property to disable code shrink - Add build property to include dependency info in apk/app bundle
This commit is contained in:
@@ -10,10 +10,17 @@ plugins {
|
||||
alias(libs.plugins.aboutLibraries)
|
||||
}
|
||||
|
||||
val includeAnalytics = project.hasProperty("with-analytics")
|
||||
val includeUpdater = project.hasProperty("with-updater")
|
||||
class ConfigClass {
|
||||
val includeAnalytics: Boolean = project.hasProperty("include-analytics")
|
||||
val enableUpdater: Boolean = project.hasProperty("enable-updater")
|
||||
val enableCodeShrink: Boolean = !project.hasProperty("disable-code-shrink")
|
||||
val includeDependencyInfo: Boolean = project.hasProperty("include-dependency-info")
|
||||
}
|
||||
|
||||
if (includeAnalytics) {
|
||||
@Suppress("PropertyName")
|
||||
val Config = ConfigClass()
|
||||
|
||||
if (Config.includeAnalytics) {
|
||||
pluginManager.apply {
|
||||
apply(libs.plugins.google.services.get().pluginId)
|
||||
apply(libs.plugins.firebase.crashlytics.get().pluginId)
|
||||
@@ -34,9 +41,8 @@ android {
|
||||
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
||||
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
|
||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
|
||||
buildConfigField("boolean", "INCLUDE_ANALYTICS", "$includeAnalytics")
|
||||
buildConfigField("boolean", "INCLUDE_UPDATER", "$includeUpdater")
|
||||
buildConfigField("boolean", "PREVIEW", "false")
|
||||
buildConfigField("boolean", "ANALYTICS_INCLUDED", "${Config.includeAnalytics}")
|
||||
buildConfigField("boolean", "UPDATER_ENABLED", "${Config.enableUpdater}")
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -48,17 +54,20 @@ android {
|
||||
isPseudoLocalesEnabled = true
|
||||
}
|
||||
val release by getting {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
isMinifyEnabled = Config.enableCodeShrink
|
||||
isShrinkResources = Config.enableCodeShrink
|
||||
|
||||
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
|
||||
}
|
||||
|
||||
val commonMatchingFallbacks = listOf(release.name)
|
||||
|
||||
create("foss") {
|
||||
initWith(release)
|
||||
|
||||
applicationIdSuffix = ".t-foss"
|
||||
applicationIdSuffix = ".foss"
|
||||
|
||||
matchingFallbacks.add(release.name)
|
||||
matchingFallbacks.addAll(commonMatchingFallbacks)
|
||||
}
|
||||
create("preview") {
|
||||
initWith(release)
|
||||
@@ -68,9 +77,7 @@ android {
|
||||
versionNameSuffix = debug.versionNameSuffix
|
||||
signingConfig = debug.signingConfig
|
||||
|
||||
matchingFallbacks.add(release.name)
|
||||
|
||||
buildConfigField("boolean", "PREVIEW", "true")
|
||||
matchingFallbacks.addAll(commonMatchingFallbacks)
|
||||
}
|
||||
create("benchmark") {
|
||||
initWith(release)
|
||||
@@ -82,12 +89,12 @@ android {
|
||||
|
||||
signingConfig = debug.signingConfig
|
||||
|
||||
matchingFallbacks.add(release.name)
|
||||
matchingFallbacks.addAll(commonMatchingFallbacks)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val analyticsDir = if (includeAnalytics) "analytics-firebase" else "analytics-firebase-noop"
|
||||
val analyticsDir = if (Config.includeAnalytics) "analytics-firebase" else "analytics-firebase-noop"
|
||||
getByName("main").kotlin.srcDirs("src/$analyticsDir/kotlin")
|
||||
getByName("preview").res.srcDirs("src/debug/res")
|
||||
getByName("benchmark").res.srcDirs("src/debug/res")
|
||||
@@ -131,7 +138,8 @@ android {
|
||||
}
|
||||
|
||||
dependenciesInfo {
|
||||
includeInApk = false
|
||||
includeInApk = Config.includeDependencyInfo
|
||||
includeInBundle = Config.includeDependencyInfo
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
@@ -273,7 +281,7 @@ dependencies {
|
||||
implementation(libs.logcat)
|
||||
|
||||
// Crash reports/analytics
|
||||
if (includeAnalytics) {
|
||||
if (Config.includeAnalytics) {
|
||||
implementation(platform(libs.firebase.bom))
|
||||
implementation(libs.firebase.analytics)
|
||||
implementation(libs.firebase.crashlytics)
|
||||
|
||||
Reference in New Issue
Block a user