如何通过Gradle将编译器参数传递给Kotlin编译器 [英] How to pass compiler arguments to Kotlin Compiler with Gradle

查看:239
本文介绍了如何通过Gradle将编译器参数传递给Kotlin编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



apply plugin:'kotlin'

我正在用Gradle编译一个Kotlin库jar,使用Kotlin gradle插件。 $ c
$ b

我试图找到一种方法来将一个简单的 -include-runtime 编译器参数传递给kotlin编译器。我似乎无法找到关于此的任何文档。我尝试模仿java插件,但似乎没有工作。 这里是关于使用命令行编译器的一些文档,但gradle文档不会并不提及任何有关传递编译器参数的信息。

解决方案

一种传递任意编译器选项的方法:

  kotlinOptions {
freeCompilerArgs = ['-include-runtime']
}


I'm compiling a Kotlin library jar with Gradle using the Kotlin gradle plugin:

apply plugin: 'kotlin'

I'm trying to find a way to pass a simple -include-runtime compiler arguments to the kotlin compiler. I can't seem to find any documentation on this at all. I tried mimicking the java plugin, but that didn't seem to work. Here is some documentation about working with the command line compiler, but the gradle documentation doesn't mention anything about passing compiler arguments.

解决方案

A way to pass arbitrary compiler options:

kotlinOptions {
    freeCompilerArgs = ['-include-runtime']
}

这篇关于如何通过Gradle将编译器参数传递给Kotlin编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆