What is the `multiplatform-setup` and the `multipl...
# compose-desktop
s
What is the
multiplatform-setup
and the
multiplatform-compose-setup
plugins? First time I’m seeing the
multiplatform-setup
plugin.
j
I didn't see them, can you share links?
s
They are used in the todoapp in all the common modules. My assumption is that they are cheaper options for libraries, but I’m having trouble resolving them locally. Currently investigating. https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/common/root/build.gradle.kts#L2-L3
s
yes - I just found them in the buildSrc.
it seems like it’s basically just a simple way for them to share buildscript configuration. Never seen it done quite like this. I like it.
j
Yep, if you have a lot of modules, they are very useful. Or if you have a lot of code in one gradle file, you can extract some configuration to precompiled plugins. For example I have precompiled plugins for Detekt and DependencyUpdates so I can apply them in the root file so:
Copy code
plugins {
    Detekt
    DependencyUpdates
}
a
I found this approach by accident and the Todo sample is the first time I used precompiled scripts. Also liked it. Here is the article which I bumped into when I was writing this sample: https://proandroiddev.com/sharing-build-logic-with-kotlin-dsl-203274f73013
s
So I was confused why I couldn’t find the buildscript for the todo app. It appears the buildscript is inside the build.gradle.kts file for the buildSrc. I’ve never seen this before. I’m also not understanding what these lines do: https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/buildSrc/build.gradle.kts#L37-L40
j
If you define the plugins inside dependencies block in buildSrc, you don't need to explicit the version when you use them later
s
didn’t know that. I’ll try it out. Do you know what this line is doing?
Copy code
sourceSets.getByName("main").kotlin.srcDir("buildSrc/src/main/kotlin")
j
Check the comment above it
You can see there is a buildSrc inside buildSrc
without that approach, you cant access to Deps.kt object inside
s
You can see there is a buildSrc inside buildSrc
Missed that! So there is!
j
I would like to know what is this:
kotlin-dsl-precompiled-script-plugins
@Arkadii Ivanov do you know about that plugin?
s
that line makes sense now. It’s sharing the sources for the nested buildSrc with the root buildSrc.
a
@Javier I found this in the above article, thought it is required for precompiled scripts.
s
is the buildSrc inside of buildSrc really necessary?
j
I didn't need it for precompiled plugins but I had problems to creating extension functions for
KotlinSourceSet
for example, and I was wondering if this plugin could solve it 🤔
Yes if you want to use Deps or Versions inside buildSrc
s
Ah, you mean the buildSrc build.gradle file. That makes sense
j
but I use it in different way to keep all the logic inside the first buildSrc so you don't have to enter never inside the second buildSrc
a
I'm not 100% sure why this plugin is needed. I could check later if we can remove it. Currently I remember there some issues without it.
s
I too have struggled to add extension functions to
KotlinSourceSet
j
root/buildSrc
root/buildSrc/buildSrc
root/buildSrc/buildSrc/build.gradle.kts
You can add there Dependencies too
@Arkadii Ivanov if you find problems, please share them here 😄
a
Will do
👍 1
j
@spierce7 if you find a way to solve the problem where
kotlin
is an unresolved reference ping me too please
s
I tried months ago to be able to add a list to
implementation
dependencies
multiplatform plugin doesn’t allow a list of dependencies, while others do. I’ve given up on messing with that
j
a
@JavierLooks like the article I derived this code is a bit outdated. I think
kotlin-dsl
plugin now implicitly applies
kotlin-dsl-precompiled-script-plugins
plugin.
The latter can be removed now.
j
Thank you 🙂