【问题标题】:Maven multiple compiler argumentsMaven 多个编译器参数
【发布时间】:2015-05-14 14:23:13
【问题描述】:

我通过传递参数 -XDignore.symbol.file

使用 javac 编译一个类

同样,我想在 maven pom.xml 中使用相同的。

<configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <encoding>UTF-8</encoding>
                        <compilerArgument>-Xlint:all -XDignore.symbol.file</compilerArgument>
                        <showWarnings>true</showWarnings>
                        <showDeprecation>true</showDeprecation>
                    </configuration> 

以上配置不工作。有什么想法???

【问题讨论】:

  • 顺便说一句:你使用哪个版本的 maven-compiler-plugin?

标签: maven maven-2 maven-3 pom.xml


【解决方案1】:

首先你应该使用this:

<compilerArgs>
  <arg>-Xmaxerrs=1000</arg>
  <arg>-Xlint</arg>
</compilerArgs>

或者您可以使用following:

<compilerArguments>
  <Xmaxerrs>1000</Xmaxerrs>
  <Xlint/>
  <Xlint:-path/>
  <Averbose>true</Averbose>
</compilerArguments>

此外,您为什么要手动定义 &lt;encoding&gt;...&lt;/encoding&gt; 而不使用该属性:

<project>
  ...
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  ...
</project>

以上属性将由maven-compiler-plugin自动领取

【讨论】:

    猜你喜欢
    • 2014-04-13
    • 2010-09-21
    • 2021-11-05
    • 1970-01-01
    • 2015-03-12
    • 1970-01-01
    • 2017-05-05
    • 1970-01-01
    • 2013-03-07
    相关资源
    最近更新 更多