anyone have any good ideas for dealing w\ release VS debug builds in compose apps? when I produce th...
a
anyone have any good ideas for dealing w\ release VS debug builds in compose apps? when I produce the release installers, i want to be able to detect that and do something different in my logic
d
You may look at this Gradle plugin: https://github.com/yshrsmz/BuildKonfig It adds BuildConfig like on Android. And you can pass different constants to it before the compilation process.
Also, you can run a release type by default. And for a debug type, pass additional arguments to the gradle command line.
./gradlew :run --args="my cmd args"
Copy code
fun main(args: Array<String>) {
    for (arg in args) {
        println(arg) 
        // It will print:
        // "my"
        // "cmd"
        // "args"
    }
}
For example, real code:
Copy code
val DEBUG_MODE = if (args.getOrNull(0) == "debug") {
    true
} else {
    false
}
./gradlew :run --args="debug"
And configure run configuration in IDE like this:
a
thanks for the reply!
ya i was hoping to have it backed into the gradle script some how, so it wasn't something you had to remember to setup for new developers and what not
I'm using that BuildKonfig for other things already, but not sure if I can change it only for the "packageRelease" tasks
d
In BuildKonfig doc there are part with flavors: https://github.com/yshrsmz/BuildKonfig#product-flavor
From my perspective, better to simply use standard jvm args, like I described above with
fun main(args)
But surely you can choose the best that you want
a
I hadn't seen the build flavor part of BuildKonfig before, might give that a try, thanks for your feedback!