frank
05/30/2020, 11:36 PMval backend by creating{}
val webapp by creating{}
Ilya Goncharov [JB]
06/01/2020, 9:10 AMorg.jetbrains.kotlin.multiplatform
plugin?frank
06/01/2020, 11:55 AMplugins {
kotlin("js") version "1.4-M1"
}
repositories {
maven("<https://dl.bintray.com/kotlin/kotlin-eap>")
jcenter()
mavenCentral()
}
kotlin {
sourceSets {
val commonMain by creating {
dependencies {
implementation(kotlin("stdlib-js"))
}
}
val backend by creating{
group = "org.example"
version = "1.0.0"
target {
nodejs()
produceExecutable()
}
dependencies {
implementation(kotlin("stdlib-js"))
}
}
val webapp by creating{
group = "org.example"
version = "1.0.0"
target {
browser()
produceExecutable()
}
dependencies {
implementation(kotlin("stdlib-js"))
implementation("org.jetbrains.kotlinx:kotlinx-html-js:$html_version")
implementation("io.socket:socket.io-client:1.0.0"){
exclude("or.json","json") // excluding org.json which is provided by Android
}
}
}
}
}
Ilya Goncharov [JB]
06/01/2020, 1:04 PMtarget {
...
}
is code, which configure per module, it is for configure full JS target, not only one source set.
Honestly, for now we don’t fully support multiple source sets.
For your case, I think you can use multi module Gradle build.
- root
- common Kotlin/JS module
- backend Kotlin/JS module
- webapp Kotlin/JS module
And use dependencies like this
backend
dependencies {
implementation(project("common"))
}
frank
06/01/2020, 3:03 PMDo you faced with some red code or build problem?
when I run build task I have 2 problems:
1 - ':compileKotlinJs' task going to search kotlin classes to 'main' no other sourceSets(backed etc...).
2- :browserProductionWebpack task not found other JS libraries.
I think than having multiples sourceSets gives me this problems.
With Kotlin MPP, Can i configure multiples JS Projects by sourceSets?
Jetbrains planning to increase support for multiple sourceSets?Ilya Goncharov [JB]
06/01/2020, 3:11 PMJetbrains planning to increase support for multiple sourceSets?Yes, I think you need so called HMPP in 1.4 release, but for now it is in experimenting mode for mobile multiplatform
With Kotlin MPP, Can i configure multiples JS Projects by sourceSets?You need to declare tasks for your source sets manually, so it will be very inconvenient. I am making refactorings time by time to make it easier to work with multiple source sets. But for now it is not this time unfortunately. ANd in fact tasks will be added for
main
and test
source sets.
Could you please link me to this Kotlin/MPP sample project?frank
06/01/2020, 5:20 PMIlya Goncharov [JB]
06/01/2020, 5:34 PMcommonMain
and jsMain
to declare dependencies
(And you send one link twice, but I understand, what you mean)
And with these source sets everything will work, but commonMain
is place for common non platfrom-specific code.
About HMPP there will be articles, but for now I am not sure :(frank
06/01/2020, 5:59 PMIlya Goncharov [JB]
06/01/2020, 6:00 PMfrank
06/01/2020, 6:06 PM