gpt4 book ai didi

java - 将选项/参数文件传递给 Maven 编译器插件

转载 作者:行者123 更新时间:2023-11-30 06:49:07 26 4
gpt4 key购买 nike

javac 命令可以通过在命令行上使用 @ 指定文件来配置文件:

javac @compileargs

我想在 Maven 中使用该语法,这样我就可以在这样的文件中收集部分命令行参数,而不是 Maven 的 pom.xml

Maven 编译器插件 does not seem to have一个特定的标签,所以我尝试了 compilerArgs :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<compilerArgs>
<arg>@compile-args</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
</plugin>

但是 javac 提示:

javac: invalid flag: @compile-args
Usage: javac <options> <source files>
use --help for a list of possible options

不过,如果我得到 Maven 正在执行的实际命令(使用 -X)并自己调用它,它就可以工作。

我最近遇到了与 spaces in compiler options 类似的问题所以我假设类似的过程在这里搞砸了我。

最佳答案

背景信息:maven 编译器依赖于 plexus compiler .

如果构建过程被 fork ,它将获取所有指定的参数并自行创建一个临时配置文件(参见 the code )。参数文件还将包含用户定义的参数文件,但 documentation指出:

Use of the at sign (@) to recursively interpret files is not supported.

这意味着无法从 Maven 引用选项文件。

关于java - 将选项/参数文件传递给 Maven 编译器插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43361227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com