我怎样才能为我的Gradle Java插件设置compileOptions? [英] How can I set the compileOptions for my Gradle Java plugin?

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

问题描述

我想在我的gradle build上设置-parameters命令,以便我可以使用反射来访问参数的名称。看起来我应该在下面的结束时做这件事。

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

但是compileOptions被列为read-只有当我查看源代码时,没有setter。



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



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

  Groovy:2.3.6 
Ant:Apache Ant )版本1.9.3 2013年12月23日编译
JVM:1.8.0_40(Oracle Corporation 25.40-b25)
操作系统:Windows 7 6.1 amd64

解决方案

请尝试:

 应用插件:'java'

compileJava {
options.compilerArgs<< '-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'
    }
}

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

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

解决方案

Please try:

apply plugin: 'java'

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

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

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