https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

GarouDan

03/15/2019, 6:41 PM
Hi, When configuring a project with the
kotlin("multiplatform")
plugin we can do something like:
Copy code
val jvmMain by getting {
...
}
but how our build process knows that if we write
jvmMain2
in the variable name instead of
jvmMain
our sourceset does not exist? My motivation is that I would like to do something similar, probably using my
buildSrc
, but I don’t know which kind of magic we are using here. Is the kotlin build process somehow extracting the variable names and comparing them with the available sourcesets?
r

r4zzz4k

03/15/2019, 6:49 PM
Extracting the variable name part comes from property delegates feature. You get reflected property instance from which you can get the name. https://kotlinlang.org/docs/reference/delegated-properties.html As for the sourcesets, you just check the model of the project you have.
g

GarouDan

03/15/2019, 6:58 PM
Hum, thanks, indeed. I’ve already read the delegates documentation but I wasn’t remembering that we could get the property name there. Thanks
4 Views