如何为我的 Gradle Java 插件设置 compileOptions? [英] How can I set the compileOptions for my Gradle Java plugin?

查看:35
本文介绍了如何为我的 Gradle Java 插件设置 compileOptions?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 gradle 构建中设置 -parameters 命令,以便我可以使用反射来访问参数的名称.似乎我应该使用以下闭包来做到这一点.

I want to set the -parameters command on my gradle build so that I can use reflection to access the name of the parameters. It seems like I should be doing this with the following closure.

compileJava {
    compileOptions {
        compilerArgs << '-parameters'
    }
}

但是 compileOptions 被列为只读,当我查看源代码时,没有设置器.

But compileOptions is listed as read-only, and when I look at the source code there's no setter.

https://gradle.org/docs/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html#org.gradle.api.tasks.compile.JavaCompile:options

我如何才能告诉 javac 编译器在 Gradle 中使用哪些参数?

How am I suppose to be able to tell the javac compiler what args to use in Gradle?

Groovy:       2.3.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_40 (Oracle Corporation 25.40-b25)
OS:           Windows 7 6.1 amd64

推荐答案

请尝试:

apply plugin: 'java'

compileJava {
    options.compilerArgs << '-parameters' 
}

这篇关于如何为我的 Gradle Java 插件设置 compileOptions?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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