[英]How to pass command line options to the java compiler through the <javac> Ant task using <compilerarg value=“”>?
要使用预览功能编译代码, javac
需要选项--enable-preview
和--release
。
如果我使用line
属性将这些选项传递给<javac>
Ant 任务(Ant 1.10.5),如下所示,编译成功。
<compilerarg line="--enable-preview --release 15"/>
但是,如果我使用value
属性将它们作为单独的 arguments 传递,如下所示, Ant 会抛出error: invalid flag: --release 15
。
<compilerarg value="--enable-preview"/>
<compilerarg value="--release 15"/>
由于 Ant 手册说“强烈建议尽可能避免使用 line 版本”,我想知道如何使代码也与value
属性一起使用。 有什么诀窍?
需要三个 arguments,比如:
<compilerarg value="--enable-preview"/>
<compilerarg value="--release"/>
<compilerarg value="15"/>
...否则,如您所见,“--release 15”被视为具有嵌入空间的单个参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.