Hello Everyone, I want to create a small plugin in...
# multiplatform
a
Hello Everyone, I want to create a small plugin in buildSrc for Kotlin Multiplatform, so that when I apply my custom configuration it would build selectively the source sets. Lets say I am on linux, and have iosMain target, I want to disable this target in the whole project with a flag. Do you have any ideas where I could start?
z
Generally, you can just apply a different set of platforms based on whatever conditions you have. I do something similar here, though not in
buildSrc
so your overall syntax may vary. But basically, this sort of setup:
Copy code
kotlin {
    if (iAmOnLinux) {
        jvm()
        android()
    } else {
        jvm()
        android()
        iosMain()
    }
}
K 1
a
Thank you, for the reply. Yeah I want to do something similar, and stuff it in a plugin because I have multimodule setup, and I am thinking that custom plugin would be easier/cleaner to apply, and turn off/on with a flag. This also looks simple enough though.