intelliJ在多平台项目中把kotlin.js放在哪里?
当使用IntelliJ创建一个Multiplatform项目时,似乎并没有为js项目创建kotlin.js(std lib)。
正如在提到kotlin.js
的文档中所说 :
注意:…在Maven或Gradle构建中,默认情况下没有将库文件复制到编译输出目录,请参阅相应的教程以获取指示信息。
Kotlin Multiplatform项目构建总是使用Gradle运行,并且您需要参考Gradle教程 ,其中说:
默认情况下,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目录。