I'm trying to use better-parse library in the Kotlin multiplatform (JS/JVM) project and it's not visible in any module. Link to sample project.
Here is build.gradle.kts
:
plugins {
kotlin("multiplatform") version "1.6.20"
}
group = "llesha"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
mavenLocal()
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
testRuns["test"].executionTask.configure {
useJUnit()
}
}
js(IR) {
browser()
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.github.h0tk3y.betterParse:better-parse:0.4.4")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val jsMain by getting
val jsTest by getting
}
}
I don't think that library is the problem, because it works in the Kotlin/JVM project with Kotlin 1.6.20. Also it is shown in the External libraries as if it is imported:
I tried using api
instead of implementation
, moved dependency to the test module, moved dependencies to the root level like so:
dependencies {
"commonMainImplementation"("com.github.h0tk3y.betterParse:better-parse:0.4.4")
}
But none of that is working.
Also I noticed that if the library is added to the jvm module, it works. But in js module it does not. Here is a modified sourceSets
script for this:
...
val jvmMain by getting {
dependencies {
implementation("com.github.h0tk3y.betterParse:better-parse-jvm:0.4.4")
}
}
val jvmTest by getting
val jsMain by getting {
dependencies {
implementation("com.github.h0tk3y.betterParse:better-parse-js:0.4.4")
}
}
...
By changing the kotlin version to kotlin("multiplatform") version "1.9.22"
I made it work!