我正在尝试将我的 Kotlin 应用程序和一组 Kotlin 库编译为 JavaScript。我已经运行得很好,但是当我尝试运行它时,它找不到 kotlin.js
。
那么这是怎么回事?当我使用 IDEA(而不是 Gradle)进行编译时,它输出 kotlin.js
效果很好。我尝试使我的构建脚本更像我发现的示例,but that wouldn't compile ...
以下是相关代码和项目的链接:https://github.com/BlueHuskyStudios/Decision-Cruncher/blob/SO/q/53582651/1/build.gradle
最佳答案
这只对我有用。 unzip
由于某种原因无法正常工作
task assembleWeb() {
configurations.implementation.setCanBeResolved(true)
configurations.implementation.each { File file ->
if (file.path.indexOf('kotlin-stdlib-js') >= 0) {
exec {
workingDir "$projectDir/web"
standardOutput = new ByteArrayOutputStream()
commandLine "7z", "e", file.absolutePath, "kotlin.js", "-aos", "-r"
}
}
}
dependsOn classes
}
assemble.dependsOn assembleWeb
注意“-aos”
参数。该标志将防止覆盖现有文件
关于Gradle 不发出 kotlin.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53582651/