https://kotlinlang.org logo
Title
s

spierce7

04/24/2023, 3:11 PM
I've got a Compose app that is using multiple JVM targets ("internal", and "production"). I was pretty sure this wouldn't work, but somehow it is. When I call
./gradlew :app:run
compose seems to be targeting the internal variant. I've changed the order, and no matter what it seems to choose the internal variant. Is there a way to choose what variant is run?
val flavorAttribute = Attribute.of("com.example.flavor", String::class.java)

kotlin {
    jvm("jvmInternal") {
        attributes.attribute(flavorAttribute, "internal")
        compilations.all {
            kotlinOptions.jvmTarget = "17"
        }
    }

    jvm("jvmProduction") {
        attributes.attribute(flavorAttribute, "production")
        compilations.all {
            kotlinOptions.jvmTarget = "17"
        }
    }
o

Oleksandr Karpovich [JB]

04/24/2023, 3:37 PM
I guess something like this could help:
compose.desktop {
    application {
        ....
        from(kotlin.targets.getByName("jvmProduction"))
    }
}
To avoid the hardcoding, you’ll need to add some gradle property and if..else.
s

spierce7

04/24/2023, 4:06 PM
thank you