Skip to content

Commit

Permalink
feat: android flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
storytellerF committed Oct 18, 2024
1 parent 905aeb1 commit 00f4603
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 22 additions & 8 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.BOOLEAN
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
import com.google.common.base.CaseFormat
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
Expand All @@ -18,6 +20,11 @@ plugins {

val buildIosTarget = project.findProperty("target.ios") == true
val buildWasmTarget = project.findProperty("target.wasm") == true
val flavor = project.findProperty("buildkonfig.flavor") as String
val flavorTaskName = CaseFormat.LOWER_HYPHEN.converterTo(CaseFormat.LOWER_CAMEL).convert(flavor)!!
val flavorId = CaseFormat.LOWER_HYPHEN.converterTo(CaseFormat.LOWER_UNDERSCORE).convert(flavor)!!
val isProd = project.findProperty("server.prod") == true

kotlin {
if (buildWasmTarget) {
@OptIn(ExperimentalWasmDsl::class)
Expand Down Expand Up @@ -160,6 +167,14 @@ android {
excludes += listOf("/META-INF/{AL2.0,LGPL2.1}", "META-INF/versions/9/OSGI-INF/MANIFEST.MF")
}
}
flavorDimensions += "server"
productFlavors {
create(flavorTaskName) {
applicationIdSuffix = ".$flavorId"
dimension = "server"
versionNameSuffix = "-$flavorId"
}
}
buildTypes {
getByName("debug") {
applicationIdSuffix = ".debug"
Expand All @@ -185,16 +200,15 @@ android {
}
}

val flavor = project.findProperty("buildkonfig.flavor") as String
val isProd = project.findProperty("server.prod") == true

easylauncher {
productFlavors {
register(flavorTaskName) {
filters(chromeLike(label = flavor))
}
}
buildTypes {
register("debug") {
filters(greenRibbonFilter("debug"), chromeLike(label = flavor))
}
register("release") {
filters(chromeLike(label = flavor))
filters(greenRibbonFilter("debug"))
}
}
}
Expand Down Expand Up @@ -268,5 +282,5 @@ val decodeBase64ToStoreFileTask = tasks.register("decodeBase64ToStoreFile") {
}

afterEvaluate {
tasks.getByName("packageRelease").dependsOn(decodeBase64ToStoreFileTask)
tasks["package${flavorTaskName.uppercaseFirstChar()}Release"]?.dependsOn(decodeBase64ToStoreFileTask)
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fun <T : Identifiable> LazyListScope.nestedStateView(items: LazyPagingItems<T>,
}
}

is LoadStateNotLoading -> {
else -> {
items(items.itemCount, key = items.itemKey {
it.id.toString()
}, contentType = items.itemContentType()) {
Expand Down

0 comments on commit 00f4603

Please sign in to comment.