我有一个Kotlin Gradle项目,我想将Kotlin的运行时和stdlib包含在jar文件中.我目前正在使用它,但是当我使用build.gradle配置构建项目时,它不包括运行时或stdlib.
compileKotlin {
kotlinOptions {
includeRuntime = true
noStdlib = false
}
}
Run Code Online (Sandbox Code Playgroud)
这是我用来在jar中包含运行时/ stdlib的Gradle代码,但它不像我期望的那样工作.以下是某些上下文的完整build.gradle文件:https: //github.com/BenWoodworth/CrossPlatformGreeter/blob/bd1da79f36e70e3d88ed871bc35502ecc3a852fb/build.gradle#L35-L43
Kotlin的Gradle文档似乎表明将kotlinOptions.includeRuntime设置为true应该在生成的.jar中包含Kotlin运行时.
https://kotlinlang.org/docs/reference/using-gradle.html#attributes-specific-for-kotlin
编辑: 这可能是相关的.当我运行compileKotlin时,我收到了一些与运行时相关的警告:
:compileKotlin
w: Classpath entry points to a non-existent location: <no_path>\lib\kotlin-runtime.jar
BUILD SUCCESSFUL
Run Code Online (Sandbox Code Playgroud)