Can anybody tell me how to properly set up a Compo...
# compose-desktop
m
Can anybody tell me how to properly set up a Compose multiplatform library project. There does not seem to be any specific template for that. If there is no better approach I would like to start from a Kotlin multiplatform library project created by the Idea “New project” wizard and then extend that to support Compose. Whatever I have tried so far there always seems to be something missing. For the time being support for Android and Desktop would be enough.
I am using the latest IntelliJ IDEA:
Copy code
IntelliJ IDEA 2022.1.1 RC (Community Edition)
Build #IC-221.5591.41, built on May 5, 2022
Runtime version: 11.0.14.1+1-b2043.45 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.3.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Non-Bundled Plugins:
    com.intellij.javafx (1.0.4)
    org.asciidoctor.intellij.asciidoc (0.37.17)
    com.gluonhq.plugin.intellij (2.8.6)
    androidx.compose.plugins.idea (221.5591.19)

Kotlin: 221-1.6.21-release-337-IJ5591.41
b
https://github.com/mpetuska/kmdc/blob/master/buildSrc/src/main/kotlin/plugin.library-compose.gradle.kts Follow the precompiled script plugin trail and just add missing targets.
Compose lib is no different than any other mpp lib. Just add compose plugin and dependencies.
a
I just checked this page and this is what I came up with.
🙏 1
👍 1
m
Thanks to all. I’ll have to dive into that a bit more.
@Albert Chang Your example was maximally helpful 🙏. I could fix my library setup and everything works like a charm now. There is one thing which I do not understand though. Why do you duplicate all the Compose dependency entries in the source set configurations? It does not seem to be needed (at least in my case). I only have them once in commonMain.
a
I'm specifying the jetpack versions for Android and jetbrains versions for desktop because it was a android-only library and I don't want to change the versions of the jetpack dependencies.
🙏 1