在 Gradle 中设置 IntelliJ 编译器参数 [英] Setting IntelliJ compiler args in Gradle
问题描述
我需要添加 -parameters
java 编译器参数以使我的测试成功.我可以在 gradle 中做到这一点,以便 ./gradlew build
工作,或者通过在 IntelliJ Settings > 下手动添加
所以它们在 IDE 中工作,但我不希望每个检查这个 repo 的人都必须做一个手动步骤.-parameters
构建.. >编译器Java编译器额外的命令行参数:
I need to add the -parameters
java compiler parameter for my tests to succeed. I can do this in gradle already for ./gradlew build
to work, or manually by adding -parameters
under IntelliJ Settings > Build.. > Compiler > Java Compiler > Additional command line parameters:
so they work in the IDE, but I don't want everyone who checks out this repo to have to do a manual step.
我的 .ipr
文件确实显示了
My .ipr
file does show
<代码><组件名称="JavacSettings"><option name="ADDITIONAL_OPTIONS_STRING" value="-parameters"/></component>
手动设置后,是否可以在gradle中配置idea插件,让./gradlew idea
完成所有工作?
after setting it manually, but is it possible to configure the idea plugin in gradle so ./gradlew idea
just does all the work?
推荐答案
使用 JetBrains 的新概念验证"插件可以做到这一点:gradle-idea-ext-plugin 具有以下配置:
It's possible to do that with the new "Proof-of-concept" plugin from JetBrains: gradle-idea-ext-plugin with following configuration:
idea.project.settings {
compiler {
javac {
javacAdditionalOptions "-parameters"
}
}
}
这篇关于在 Gradle 中设置 IntelliJ 编译器参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!