Hey, having all of these source sets is great, but...
# multiplatform
m
Hey, having all of these source sets is great, but in Compose we are using desktopMain as well, I think it would be nice to have it as well when we add jvm("desktop") target.
z
The problem is that
"desktop"
in that case is a dynamic name for a JVM target, you could call it anything, and these source set accessors are static, pre-defined properties (implemented here). So you can either get the source set the regular way
Copy code
sourceSets {
    val desktopMain by getting
    desktopMain.dependencies {
        implementation(compose.desktop.currentOs)
    }
}
Or if you really want an accessor that has autocompletion and is the same as the others, you can define one yourself
Copy code
// Somewhere in scope, like top level in the Gradle build file
val NamedDomainObjectContainer<KotlinSourceSet>.desktopMain by KotlinSourceSetConvention

// In the kotlin{} block
sourceSets {
    desktopMain.dependencies {
        implementation(compose.desktop.currentOs)
    }
}
thank you color 2
j
On a related topic, if you name a target's source set like
jvm("desktop")
, does it still get connected into the default hierarchy template the same as if it had the default
jvm
source set name?
z
Well, the
jvm
target in the default hierarchy really just depends on
common
, so... I suppose the answer is yes. It will definitely depend on
common
.
j
Haha, I guess the
jvm
target was a bad example. But if you were to rename a native target, for example, would it still get connected to the hierarchy in the same way?
(Personally I'm hoping the default hierarchy template will adopt a shared JVM + Android intermediate source set eventually!)
z
I believe you should be able to rename targets and keep using the hierarchy, yes.
j
Great, thanks.