Skip to content

Commit 3aa897d

Browse files
ddolovovdkrasnoff
authored andcommitted
Use KlibLoader API to check if the path points to a real KLIB
Don't use obsolete `isKotlinLibrary()` function that is going to be phased out.
1 parent f6c9e78 commit 3aa897d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

common/src/main/kotlin/component/KotlinEnvironment.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package component
22

3-
import org.jetbrains.kotlin.library.impl.isKotlinLibrary
3+
import org.jetbrains.kotlin.library.loader.KlibLoader
4+
import org.jetbrains.kotlin.library.loader.KlibPlatformChecker
45
import java.io.File
56

67
// NOTE: if new class paths are added, please add them to `JavaExec` task's inputs in build.gradle.kts as well
@@ -41,13 +42,13 @@ class KotlinEnvironment(
4142

4243
val JS_LIBRARIES = additionalJsClasspath
4344
.map { it.absolutePath }
44-
.filter { isKotlinLibrary(File(it)) }
45+
.filter { isJsKlib(it) }
4546
val WASM_LIBRARIES = additionalWasmClasspath
4647
.map { it.absolutePath }
47-
.filter { isKotlinLibrary(File(it)) }
48+
.filter { isWasmKlib(it) }
4849
val COMPOSE_WASM_LIBRARIES = additionalComposeWasmClasspath
4950
.map { it.absolutePath }
50-
.filter { isKotlinLibrary(File(it)) }
51+
.filter { isWasmKlib(it) }
5152
val COMPOSE_WASM_COMPILER_PLUGINS = composeWasmCompilerPlugins
5253
.map { it.absolutePath }
5354

@@ -59,4 +60,13 @@ class KotlinEnvironment(
5960
return f()
6061
}
6162

63+
private fun isJsKlib(path: String) = KlibLoader {
64+
libraryPaths(path)
65+
platformChecker(KlibPlatformChecker.JS)
66+
}.load().librariesStdlibFirst.isNotEmpty()
67+
68+
private fun isWasmKlib(path: String) = KlibLoader {
69+
libraryPaths(path)
70+
platformChecker(KlibPlatformChecker.Wasm())
71+
}.load().librariesStdlibFirst.isNotEmpty()
6272
}

0 commit comments

Comments
 (0)