Hey I currently have this giant codeblock to defin...
# multiplatform
j
Hey I currently have this giant codeblock to define my apple kotlin targets:
Copy code
val appleMain by creating {
    dependsOn(commonMain)
}
val appleTest by creating {
    dependsOn(commonTest)
}
val iosMain by getting {
    dependsOn(appleMain)
}
val macosMain by creating {
    dependsOn(appleMain)
}
val macosX64Main by getting {
    dependsOn(macosMain)
}
val macosArm64Main by getting {
    dependsOn(macosMain)
}
val iosSimulatorArm64Main by getting {
    dependsOn(iosMain)
}
val iosSimulatorArm64Test by getting {
    dependsOn(appleTest)
}
However, I have 5 different modules at which it gets really hard to maintain all of them. Can I somehow make an extension function to automatically do this, what the code from above is doing? (prob more of a gradle question)
j
You will appreciate the new
targetHierarchy
API: https://kotlinlang.org/docs/multiplatform-hierarchy.html
You can also move the logic to a convention plugin to apply to multiple modules.
of course you can do
targetHierarchy.default
in a convention plugin too
j
great, thanks!
e
as https://kotlinlang.org/docs/whatsnew1820.html#new-approach-to-source-set-hierarchy says, if you have any feedback on the feature, they'd like to hear about it