Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better flavors & Room Gradle Plugin (trying to fix CI) #243

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.ksp)
alias(libs.plugins.room)
}

fun readProperties(file: File): Properties {
Expand Down Expand Up @@ -46,10 +47,6 @@ android {
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}

buildConfigField(
"String",
"LASTFM_API_KEY",
Expand Down Expand Up @@ -151,17 +148,24 @@ android {
}
}

flavorDimensions += "channel"
flavorDimensions += listOf("channel", "updater")
productFlavors {
create("nongoogle") {
create("nonGoogle") {
dimension = "channel"
isDefault = true
}
create("google") {
dimension = "channel"
}
create("noupdater") {
dimension = "channel"

create("withUpdater") {
dimension = "updater"
isDefault = true
buildConfigField("boolean", "ENABLE_UPDATER", "true")
}
create("withoutUpdater") {
dimension = "updater"
buildConfigField("boolean", "ENABLE_UPDATER", "false")
}
}

Expand All @@ -188,6 +192,24 @@ android {
dependenciesInfo {
includeInApk = false
}

room {
schemaDirectory("$projectDir/schemas")
}
}

androidComponents {
beforeVariants { variantBuilder ->
if (variantBuilder.productFlavors.containsAll(
listOf(
"channel" to "google",
"updater" to "withUpdater"
)
)
) {
variantBuilder.enable = false
}
}
}

dependencies {
Expand Down Expand Up @@ -241,7 +263,4 @@ dependencies {

val googleImplementation by configurations
googleImplementation(libs.billingclient)

val noupdaterImplementation by configurations
noupdaterImplementation(libs.billingclient)
}
2 changes: 0 additions & 2 deletions app/src/main/java/remix/myplayer/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,5 @@ class App : MultiDexApplication() {
//是否是googlePlay版本
val IS_GOOGLEPLAY =
!BuildConfig.DEBUG && BuildConfig.FLAVOR == "google"

val ENABLE_UPDATER = BuildConfig.FLAVOR == "nonGoogle"
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/remix/myplayer/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.soundcloud.android.crop.Crop
import remix.myplayer.App
import remix.myplayer.App.Companion.ENABLE_UPDATER
import remix.myplayer.BuildConfig
import remix.myplayer.R
import remix.myplayer.bean.misc.CustomCover
import remix.myplayer.bean.misc.Library
Expand Down Expand Up @@ -699,7 +699,7 @@ class MainActivity : MenuActivity(), View.OnClickListener {
}

private fun checkUpdate() {
if (ENABLE_UPDATER && !alreadyCheck) {
if (BuildConfig.ENABLE_UPDATER && !alreadyCheck) {
UpdateAgent.forceCheck = false
UpdateAgent.listener = UpdateListener(this)
alreadyCheck = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import remix.myplayer.App.Companion.ENABLE_UPDATER
import remix.myplayer.App.Companion.IS_GOOGLEPLAY
import remix.myplayer.BuildConfig
import remix.myplayer.R
Expand Down Expand Up @@ -407,7 +406,7 @@ class SettingActivity : ToolbarActivity(), ColorChooserDialog.ColorCallback,
}
}.start()

if (!ENABLE_UPDATER) {
if (!BuildConfig.ENABLE_UPDATER) {
binding.settingUpdateContainer.visibility = View.GONE
}

Expand Down
13 changes: 0 additions & 13 deletions app/src/noupdater/AndroidManifest.xml

This file was deleted.

244 changes: 0 additions & 244 deletions app/src/noupdater/kotlin/remix/myplayer/ui/activity/SupportActivity.kt

This file was deleted.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ plugins {
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.room) apply false
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ application = { id = "com.android.application", version.ref = "agp" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
room = { id = "androidx.room", version.ref = "room" }


[libraries]
Expand Down