yshrsmz / BuildKonfig

BuildConfig for Kotlin Multiplatform Project
Apache License 2.0
729 stars 33 forks source link

Flavor Selection Based on Build Variants in Android #153

Closed Egi10 closed 3 months ago

Egi10 commented 3 months ago

Currently, the Mobile application (iOS and Android) has build variants (staging, UAT, and prod). At present, to change the flavors, it is done through gradle.properties.

// flavor = staging, UAT, or prod
buildkonfig.flavor=prod

Is it possible to automatically run the flavor according to the selected build variant in Android without having to change the buildkonfig in gradle.properties?

yshrsmz commented 3 months ago

see https://github.com/yshrsmz/BuildKonfig/discussions/128#discussioncomment-7896350

Egi10 commented 3 months ago

I've tried this, but I always fail here:

val runningTasks = project.gradle.startParameter.taskNames where the result is always emptyList and if I add:

gradle.taskGraph.whenReady {
    configureBuildKonfigFlavorFromAndroidTasks()
}

the result is: [prepareKotlinIdeaImport, prepareKotlinBuildScriptModel]

Can you please give me a solution for this?

yshrsmz commented 3 months ago

Could you comment on the discussion https://github.com/yshrsmz/BuildKonfig/discussions/128 ? We want to keep all the relevant information/knowledge in one place 🙏

Egi10 commented 3 months ago

okey, thanks