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

Nic*_*lai 4 java maven

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

javac @compileargs
Run Code Online (Sandbox Code Playgroud)

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

Maven 编译器插件似乎没有特定的标签,所以我尝试了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>
Run Code Online (Sandbox Code Playgroud)

但随后javac抱怨:

javac: invalid flag: @compile-args
Usage: javac <options> <source files>
use --help for a list of possible options
Run Code Online (Sandbox Code Playgroud)

不过,如果我得到 Maven 正在执行的实际命令(使用-X)并称其为我自己的工作。

我最近在编译器选项中遇到了类似的空格问题,所以我认为这里有一个类似的过程。

mei*_*ier 6

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

如果构建过程被分叉,它将采用所有指定的参数并自行创建一个临时配置文件(请参阅代码)。参数文件还将包含用户定义的参数文件,但文档指出:

不支持使用 at 符号 (@) 递归解释文件。

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