Hello! I have kotlin multiplatform with several JV...
# compose-desktop
p
Hello! I have kotlin multiplatform with several JVM targets. When I'm applying org.jetbrains.compose gradle plugin, it applies to all JVM targets. I need this plugin aplIyed to only specified targets. I was trying to find this possablity in source of this plugin, but found only selectivity by compilation platform (in master there is logic excludin js and native targets). Is there any plans to include this customization in gradle plugin extension, such that user can make appropriate settings in his project's gradle script. (reference to current selectivity logic: https://github.com/JetBrains/compose-jb/blob/b00aa7d5d3052daf54d8408e239ff116f3f32[…]lin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt)
o
@alexey.tsvetkov WDYT?
a
@PHondogo could you tell us more about your use case? Specifically why do you need this customization? In general it is probably doable, but I’m not sure, what the default behaviour should be and how it should be implemented in DSL.
p
Common for api, one jvm for ui, one for backend. In project supposed to be about 50 such gradle modules, and splitting each for only api, only ui an only backend is not conviniant.
In DSL it can be implemented as parameter for compose extension with type of lambda with kotlin target as parameter and returning boolean.
For example: compose.applicable {target-> target.name == 'ui'}
Where compose is instance of gradle plugin extension
fun applicable(lambda: (KotlinTarget)->Boolean)
a
I still don’t understand, what’s the problem with current state of things? What prevents you from having
common, jvm(ui), jvm(backend)
now?
r
Looks like https://youtrack.jetbrains.com/issue/KT-27217, I think what @PHondogo is referring to is he only wants the compose plugin to apply to
jvm(ui)
, not common or backend. This came up a while back with a JVM only DI plugin in a multiplatform project too, I'll see if I can find it
p
The problem is with core compose dependencies. To be able to compile now, i need to depend on core compose libraries in backend targets. I want to include them only for ui targets.
And also don't want unneeded additional compilation passes by this plugin in backend targets.
a
Got it, seems reasonable. We will discuss, how to solve the issues better. I’ve created the issue https://github.com/JetBrains/compose-jb/issues/537 for tracking the progress/status.
p
Thanks!
l
In term of use cases, I am developing libraries and applications that target multiple UI toolkits (e.g. Swing, JavaFX, React, Jetpack Compose) using the expect/actual construct. Having the Compose plugin applied to all targets prevents this. This is a very much related to an issue I submitted previously: https://github.com/JetBrains/compose-jb/issues/352
a
We discussed the issue and decided to change the plugin, so that the plugin is applied automatically to a single JVM target, but if there are multiple (non-Android) JVM targets, Compose targets will have to be specified explicitly. This would not affect Android targets.
🎉 2