Skip to content

Commit bcaed6c

Browse files
committed
build: fix solr:ui wasmJs build issues (#4572)
Ktor 3.4+ CIO engine uses Node.js sockets (node:net) for wasmJs, which is incompatible with browser webpack targets. Split the HTTP client engine per platform: ktor-client-js (fetch API) for wasmJs browser, ktor-client-cio for desktop/JVM only. The Compose resource accessor generation tasks were not reliably wired as dependencies of the Kotlin compile tasks, notably compileKotlinWasmJs. On incremental or reordered builds the compile could fire before the accessors existed, failing with "Source file or directory not found" for the generated commonMainResourceAccessors (Drawable0/String0.commonMain.kt). Wire every compileKotlin* task to depend on all generateResourceAccessorsFor* tasks. (cherry picked from commit 7b9b3d3)
1 parent 85ca2a3 commit bcaed6c

5 files changed

Lines changed: 492 additions & 306 deletions

File tree

gradle/libs.versions.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,17 @@ kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-t
426426
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
427427
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
428428
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
429-
ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
430-
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
431-
ktor-client-contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
432-
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
433-
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
434-
ktor-client-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
435-
ktor-server-cio = { module = "io.ktor:ktor-server-cio", version.ref = "ktor" }
436-
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
437-
ktor-server-htmlBuilder = { module = "io.ktor:ktor-server-html-builder", version.ref = "ktor" }
429+
ktor-bom = { module = "io.ktor:ktor-bom", version.ref = "ktor" }
430+
ktor-client-auth = { module = "io.ktor:ktor-client-auth" }
431+
ktor-client-cio = { module = "io.ktor:ktor-client-cio" }
432+
ktor-client-contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation" }
433+
ktor-client-core = { module = "io.ktor:ktor-client-core" }
434+
ktor-client-js = { module = "io.ktor:ktor-client-js" }
435+
ktor-client-mock = { module = "io.ktor:ktor-client-mock" }
436+
ktor-client-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json" }
437+
ktor-server-cio = { module = "io.ktor:ktor-server-cio" }
438+
ktor-server-core = { module = "io.ktor:ktor-server-core" }
439+
ktor-server-htmlBuilder = { module = "io.ktor:ktor-server-html-builder" }
438440
langchain4j-bom = { module = "dev.langchain4j:langchain4j-bom", version.ref = "langchain4j-bom" }
439441
langchain4j-cohere = { module = "dev.langchain4j:langchain4j-cohere" }
440442
langchain4j-core = { module = "dev.langchain4j:langchain4j-core" }

solr/modules/jwt-auth/gradle.lockfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ com.nimbusds:nimbus-jose-jwt:10.9.1=jarValidation,testCompileClasspath,testRunti
3838
com.nimbusds:oauth2-oidc-sdk:11.37.1=jarValidation,testCompileClasspath,testRuntimeClasspath
3939
com.squareup.okhttp3:mockwebserver3:5.2.1=jarValidation,testCompileClasspath,testRuntimeClasspath
4040
com.squareup.okhttp3:mockwebserver:5.2.1=jarValidation,testCompileClasspath,testRuntimeClasspath
41-
com.squareup.okhttp3:okhttp-jvm:5.2.1=jarValidation,testCompileClasspath,testRuntimeClasspath
42-
com.squareup.okhttp3:okhttp:5.2.1=jarValidation,testCompileClasspath,testRuntimeClasspath
43-
com.squareup.okio:okio-jvm:3.16.1=jarValidation,testCompileClasspath,testRuntimeClasspath
44-
com.squareup.okio:okio:3.16.1=jarValidation,testCompileClasspath,testRuntimeClasspath
41+
com.squareup.okhttp3:okhttp-jvm:5.4.0=jarValidation,testCompileClasspath,testRuntimeClasspath
42+
com.squareup.okhttp3:okhttp:5.4.0=jarValidation,testCompileClasspath,testRuntimeClasspath
43+
com.squareup.okio:okio-jvm:3.17.0=jarValidation,testCompileClasspath,testRuntimeClasspath
44+
com.squareup.okio:okio:3.17.0=jarValidation,testCompileClasspath,testRuntimeClasspath
4545
com.tdunning:t-digest:3.3=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
4646
commons-cli:commons-cli:1.11.0=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
4747
commons-codec:commons-codec:1.22.0=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
@@ -173,12 +173,12 @@ org.glassfish.jersey:jersey-bom:4.0.2=jarValidation,runtimeClasspath,runtimeLibs
173173
org.hamcrest:hamcrest:3.0=jarValidation,testCompileClasspath,testRuntimeClasspath
174174
org.javassist:javassist:3.30.2-GA=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
175175
org.jetbrains.kotlin:kotlin-reflect:2.1.21=jarValidation,testRuntimeClasspath
176-
org.jetbrains.kotlin:kotlin-stdlib-common:2.2.20=testRuntimeClasspath
177-
org.jetbrains.kotlin:kotlin-stdlib-common:2.3.20=jarValidation
178-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0=jarValidation,testRuntimeClasspath
179-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.0=jarValidation,testRuntimeClasspath
180-
org.jetbrains.kotlin:kotlin-stdlib:2.2.20=testCompileClasspath,testRuntimeClasspath
181-
org.jetbrains.kotlin:kotlin-stdlib:2.3.20=jarValidation
176+
org.jetbrains.kotlin:kotlin-stdlib-common:2.2.21=testRuntimeClasspath
177+
org.jetbrains.kotlin:kotlin-stdlib-common:2.4.0=jarValidation
178+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.4.0=jarValidation,testRuntimeClasspath
179+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.4.0=jarValidation,testRuntimeClasspath
180+
org.jetbrains.kotlin:kotlin-stdlib:2.2.21=testCompileClasspath,testRuntimeClasspath
181+
org.jetbrains.kotlin:kotlin-stdlib:2.4.0=jarValidation
182182
org.jetbrains.kotlinx:kotlinx-serialization-bom:1.11.0=jarValidation,testRuntimeClasspath
183183
org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.11.0=jarValidation,testRuntimeClasspath
184184
org.jetbrains.kotlinx:kotlinx-serialization-core:1.11.0=jarValidation,testRuntimeClasspath

solr/modules/language-models/gradle.lockfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ com.j256.simplemagic:simplemagic:1.17=jarValidation,runtimeClasspath,runtimeLibs
3232
com.jayway.jsonpath:json-path:3.0.0=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
3333
com.knuddels:jtokkit:1.1.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
3434
com.lmax:disruptor:4.0.0=solrPlatformLibs
35-
com.squareup.okhttp3:okhttp:4.12.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
36-
com.squareup.okio:okio-jvm:3.16.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
37-
com.squareup.okio:okio:3.16.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
35+
com.squareup.okhttp3:okhttp-jvm:5.4.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
36+
com.squareup.okhttp3:okhttp:5.4.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
37+
com.squareup.okio:okio-jvm:3.17.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
38+
com.squareup.okio:okio:3.17.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
3839
com.squareup.retrofit2:converter-jackson:2.9.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
3940
com.squareup.retrofit2:retrofit:2.9.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
4041
com.tdunning:t-digest:3.3=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
@@ -162,9 +163,7 @@ org.glassfish.jersey.media:jersey-media-json-jackson:4.0.2=jarValidation,runtime
162163
org.glassfish.jersey:jersey-bom:4.0.2=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
163164
org.hamcrest:hamcrest:3.0=jarValidation,testCompileClasspath,testRuntimeClasspath
164165
org.javassist:javassist:3.30.2-GA=jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testRuntimeClasspath
165-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
166-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
167-
org.jetbrains.kotlin:kotlin-stdlib:2.2.0=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
166+
org.jetbrains.kotlin:kotlin-stdlib:2.2.21=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
168167
org.jetbrains:annotations:26.0.2=jarValidation,runtimeClasspath,runtimeLibs,testRuntimeClasspath
169168
org.jspecify:jspecify:1.0.0=annotationProcessor,compileClasspath,errorprone,jarValidation,runtimeClasspath,runtimeLibs,solrPlatformLibs,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
170169
org.junit.jupiter:junit-jupiter-api:5.6.2=jarValidation,testRuntimeClasspath

solr/ui/build.gradle.kts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ kotlin {
9191
implementation(libs.mvikotlin.main)
9292
implementation(libs.mvikotlin.logging)
9393

94-
implementation(libs.ktor.client.auth)
95-
implementation(libs.ktor.client.core)
96-
implementation(libs.ktor.client.cio)
97-
implementation(libs.ktor.client.contentNegotiation)
98-
implementation(libs.ktor.client.serialization.json)
99-
implementation(libs.squareup.okio)
94+
implementation(project.dependencies.platform(libs.ktor.bom))
95+
implementation(libs.ktor.client.auth)
96+
implementation(libs.ktor.client.core)
97+
implementation(libs.ktor.client.contentNegotiation)
98+
implementation(libs.ktor.client.serialization.json)
99+
implementation(libs.squareup.okio)
100100

101101
implementation(libs.oshai.logging)
102102
implementation(libs.slf4j.api)
@@ -113,8 +113,15 @@ kotlin {
113113
}
114114
}
115115

116+
val wasmJsMain by getting {
117+
dependencies {
118+
implementation(libs.ktor.client.js)
119+
}
120+
}
121+
116122
val desktopMain by getting {
117123
dependencies {
124+
implementation(libs.ktor.client.cio)
118125
implementation(libs.ktor.server.core)
119126
implementation(libs.ktor.server.cio)
120127
implementation(libs.ktor.server.htmlBuilder)
@@ -169,6 +176,14 @@ compose.desktop {
169176
}
170177
}
171178

179+
// Compose resource accessor generation is not reliably wired to all Kotlin
180+
// compile tasks (notably wasmJs), causing intermittent "source file not found"
181+
// for generated accessors. Wire it explicitly.
182+
val resourceAccessorTasks = tasks.matching { it.name.startsWith("generateResourceAccessorsFor") }
183+
tasks.matching { it.name.startsWith("compileKotlin") }.configureEach {
184+
dependsOn(resourceAccessorTasks)
185+
}
186+
172187
tasks.matching { task ->
173188
task.name in listOf(
174189
"allTests",

0 commit comments

Comments
 (0)