2017-04-12 23 views
1

javac命令可与一个文件通过指定命令行该文件被配置成与@传递一个选项/参数文件来Maven的编译器插件

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类似的问题,所以我假设一个类似的过程是在这里搞砸了我。

+0

您是否试过[compilerArgument](https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#compilerArgument)?他们可能已经在内部使用@语法来创建''标签的临时参数文件,所以你的'@ compile-args'最终会作为该文件中的一个选项 –

+0

这是什么样的问题,这就是为什么你喜欢参数在外部文件中,而不是在POM文件中?此外使用参数应该通过使用[compilerArgs](https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#compilerArgs) – khmarbaise

+1

@AndreasFester:你让我希望但'compilerArgument'导致相同的行为。 @khmarbaise:我想在选项文件中收集像'--add-modules'这样的模块系统转义码,以便它们可以被重用来启动应用程序,而不必保持'pom'和启动脚本同步。 – Nicolai

回答

3

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

如果构建过程被分叉,它将采用所有指定的参数并自行创建临时配置文件(请参阅the code)。该参数文件还将包括用户定义的参数文件,但documentation指出:at符号(@)递归解析文件

使用的是不支持的。

这意味着从Maven引用选项文件是不可能的。

相关问题