使用IntelliJ创建多平台项目时,它似乎不像创建js项目那样创建kotlin.js(std lib)。
答案 0 :(得分:3)
如文档where the kotlin.js
is mentioned中所述:
注意:...在Maven或Gradle构建中,默认情况下不会将库文件复制到编译输出目录,请参阅相应的教程以获取相关说明。
Kotlin Multiplatform项目构建始终使用Gradle运行,您需要参考Gradle tutorial,其中说:
默认情况下,Gradle不会在构建过程中扩展JAR,因此我们需要在构建中添加一个额外的步骤来执行此操作:
task assembleWeb(type: Sync) { configurations.compile.each { File file -> from(zipTree(file.absolutePath), { includeEmptyDirs = false include { fileTreeElement -> def path = fileTreeElement.path path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/")) } }) } from compileKotlin2Js.destinationDir into "${projectDir}/web" dependsOn classes } assemble.dependsOn assembleWeb
此任务将依赖项运行时文件和编译输出复制到Web目录。