kotlin - intelliJ 将 kotlin.js 放在多平台项目中的什么位置

标签 kotlin

当使用 IntelliJ 创建多平台项目时,它似乎不像 js 项目那样创建 kotlin.js (std lib)。

最佳答案

正如文档中所述 where the kotlin.js is mentioned :

Note: ... In a Maven or Gradle build, no library files are copied by default to the compilation output directory, see the corresponding tutorials for the instructions.

Kotlin Multiplatform 项目构建始终使用 Gradle 运行,您需要引用 Gradle tutorial ,其中表示:

By default, Gradle does not expand the JARs in the build process, so we need to add an additional step in our build to do so:

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

This task copies both dependencies runtime files and the compilation output to the web directory.

关于kotlin - intelliJ 将 kotlin.js 放在多平台项目中的什么位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46915905/

相关文章:

Gradle使用Kotlin DSL根据自定义任务发布

android - 子回收器 View 的预取 View 不起作用

android - 在 Kotlin 属性中使用 Dagger @Provides 注解

kotlin - 从内部 `with` 函数引用到更高级别的 `with` 函数

android - Gradle kotlin 不支持的方法 Dependencies.getAtoms()

javascript - 如何在 Typescript 中编写 Kotlinesque 扩展函数?

kotlin - 如何防止用户在文本字段中输入两个点jetpack compose

android - 从 Swift 访问 Kotlin 标准库

在集成测试的反射信息中不存在的测试中定义的 Kotlin 注释

kotlin - 为什么这个 Kotlin 方法有封闭的反引号?