Hi, is there a difference between those options? I...
# gradle
t
Hi, is there a difference between those options? I see both in examples
Copy code
kotlin {
    sourceSets {
        val commonMain by getting { /* ... */ }
    }
}
and
Copy code
kotlin {
    sourceSets {
        commonMain { /* ... */ }
    }
}
j
you will see the difference when you need it, for example if you want to create another source set which depends on commonMain
t
So, I need different way to pass parameter to dependsOn() function, like this
Copy code
kotlin {
    sourceSets {
        val commonMain by getting { /* ... */ }
        val jvmMain by getting { 
            dependsOn(commonMain)
        }
    }
}
and
Copy code
kotlin {
    sourceSets {
        commonMain { /* ... */ }
        jvmMain { 
            dependsOn(commonMain.get())
        }
    }
}
👌 1
Thanks
s
I noticed the KMP project wizard doesn't create source sets w/
dependsOn
is this implicit when using multiplatform plugin?
e.g.
expect
function defined in
commonMain
,
actual
function defined in
jvmMain
does not require
dependsOn
correct?
j
you only need depends on common when you create a new source set, the default ones don't need it
b
Typesafe commonMain is just a shortcut to your first example. Both are identical in terms of usage
j
they have different types
that is the reason you need
.get()
b
Then second example is safer as it's lazy
j
ah, I missunderstood you
b
You can pass gradle Provider to most of the dependency APIs
Just not together with actual types, but for that you can just invoke required dependency api twice
t
I am still a bit confused. e.g Why there is a
commonMain
and
jvmMain
shortcuts but not
jsMain
?
b
Just an oversight on JB part. jvmMain is fairly new
Also a lot more mpp projects use jvm target when compared to js