是否有可能让 maven 为其编译器插件接受 maxerrs? [英] Is it possible to get maven to accept maxerrs for its compiler plugin?

查看:28
本文介绍了是否有可能让 maven 为其编译器插件接受 maxerrs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,我负责修复一些错误,另一个开发人员负责其他错误.错误的数量远远超过一百个,当我修复我的错误时,她的错误正在堆积如山.我现在看到了她的 99 个错误和我的一个,我想我很快就会达到她的 100 个错误的地步.我研究过将此配置用于 maven:

<groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><配置><compilerArgument>-Xmaxerrs 1000</compilerArgument></配置></插件>

但没有骰子:

执行javac失败,但无法解析错误:javac:无效标志:-Xmaxerrs 1000用法:javac <源文件>使用 -help 获取可能选项的列表

在使用 javac 的命令行上,maxerrs 标志按预期工作,但我似乎无法使用它飞跃到 maven.

有什么想法吗?

解决方案

使用 "地图语法" 对我有用:

 <插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>2.3.1</version><配置><fork>true</fork><编译器参数><Xmaxerrs>1000</Xmaxerrs></compilerArguments></配置></插件>

该选项按预期传递:

<前>$ mvn 干净编译 -X...[调试] 使用编译器javac".[DEBUG] 源目录:[/home/pascal/Projects/stackoverflow/Q3358242/src/main/java][DEBUG] 类路径:[/home/pascal/Projects/stackoverflow/Q3358242/target/classes][DEBUG] 输出目录:/home/pascal/Projects/stackoverflow/Q3358242/target/classes[调试] 类路径:[调试]/home/pascal/Projects/stackoverflow/Q3358242/target/classes[DEBUG] 源码根:[调试]/home/pascal/Projects/stackoverflow/Q3358242/src/main/java[调试] 命令行选项:[调试] -d/home/pascal/Projects/stackoverflow/Q3358242/target/classes -classpath/home/pascal/Projects/stackoverflow/Q3358242/target/classes: -sourcepath/home/pascal/Projects/stackoverflow/Q3358242/src/main/java:/home/pascal/Projects/stackoverflow/Q3358242/src/main/java/com/stackoverflow/q3358242/App.java -g -nowarn -target 1.5 -source 1.5 -encoding UTF-8 -Xmaxerrs 1000[信息] 将 1 个源文件编译到/home/pascal/Projects/stackoverflow/Q3358242/target/classes[信息] ------------------------------------------------------------------------[信息] 构建成功[信息] ------------------------------------------------------------------------...

奇怪的是,在使用替代配置时,我得到了完全相同的调试输出(使用 完全相同 相同的命令行选项)您提供了...除了它由于执行 javac 失败而失败.你应该提出一个 Jira 问题,肯定有一些奇怪的东西.

I have a project where I am responsible for fixing some errors and another developer is responsible for other errors. The number of errors is well over a hundred, and as I'm fixing my errors, her errors are piling up. I'm at the point where I see 99 of her errors and one of mine, and I assume I will soon get to a point where it is 100 of hers. I looked into using this configuration for maven:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <compilerArgument>-Xmaxerrs 1000</compilerArgument>
  </configuration>
</plugin>

But no dice:

Failure executing javac,  but could not parse the error:
javac: invalid flag: -Xmaxerrs 1000
Usage: javac <options> <source files>
use -help for a list of possible options

On the command line using javac, the maxerrs flag works as expected, but I can't seem to make the leap to maven with it.

Any ideas?

解决方案

Using the "Map syntax" worked for me:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.1</version>
    <configuration>
      <fork>true</fork>
      <compilerArguments>
        <Xmaxerrs>1000</Xmaxerrs>
      </compilerArguments>
    </configuration>
  </plugin>

The option is passed as expected:

$ mvn clean compile -X
...
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories: [/home/pascal/Projects/stackoverflow/Q3358242/src/main/java]
[DEBUG] Classpath: [/home/pascal/Projects/stackoverflow/Q3358242/target/classes]
[DEBUG] Output directory: /home/pascal/Projects/stackoverflow/Q3358242/target/classes
[DEBUG] Classpath:
[DEBUG]  /home/pascal/Projects/stackoverflow/Q3358242/target/classes
[DEBUG] Source roots:
[DEBUG]  /home/pascal/Projects/stackoverflow/Q3358242/src/main/java
[DEBUG] Command line options:
[DEBUG] -d /home/pascal/Projects/stackoverflow/Q3358242/target/classes -classpath /home/pascal/Projects/stackoverflow/Q3358242/target/classes: -sourcepath /home/pascal/Projects/stackoverflow/Q3358242/src/main/java: /home/pascal/Projects/stackoverflow/Q3358242/src/main/java/com/stackoverflow/q3358242/App.java -g -nowarn -target 1.5 -source 1.5 -encoding UTF-8 -Xmaxerrs 1000
[INFO] Compiling 1 source file to /home/pascal/Projects/stackoverflow/Q3358242/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...

The odd part is that I get the exact same debug output (with the exact same Command line options) when using the alternative configuration you provided... except that it fails due to a Failure executing javac. You should raise a Jira issue, there is definitely something weird.

这篇关于是否有可能让 maven 为其编译器插件接受 maxerrs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆