Anybody using a buildSrc precompiled gradle kts fi...
# multiplatform
s
Anybody using a buildSrc precompiled gradle kts file to manage building / targets for a KMP library? I’ve got a repo I’m trying to update that has 5 libraries and 1 example KMP app. Currently the build.gradle.kts sets the KMP build targets for the library, but I want to move this to buildSrc and apply it directly to the libraries.
i
Instead of build source I would recommend looking at composite builds to create plugins that you apply instead which is what we do. Underlying reasoning is build cache is simplified and plugins dont have to stay lock step with your project that way and could be reused in other projects more easily in the future which we've also done.
s
Yeah it seems like buildSrc / pre compiled scripts have known limitations that aren’t communicated well. I’ll take a shot at a composite build plugin, thanks Ian!
i
I believe this is the documentation/sample code I used when I set it up for our project, hope it helps 👍 https://docs.gradle.org/current/samples/sample_composite_builds_plugin_development.html
🚀 1
s
It's not the cleanest, but its working a bit. I ended up using precompiled scripts in the buildSrc folder, and its pretty cool! https://gist.github.com/schott12521/f8195d2716b93fbcb480c78ca9cec362 I took a lot of reference from https://github.com/eduayuso/kmp-gradle-optimized/tree/main
j
#C061JJM6YUQ uses a buildSrc to provide some convention plugins to the various projects of the repository But the buildSrc also contains custom code which can be called from the gradle.kts files. This allows to bring more flexibility.
gratitude thank you 1