本文介绍了如何使Maven-compiler-plugin不隐藏错误源位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许为此有一个maven-compiler-plugin选项,但我没有找到它.

Maybe there is a maven-compiler-plugin option for this, but I haven't found it.

直接运行javac并打印错误时,在消息的第一行之后,它将显示受影响的源代码行,在下一行中的插入符号指向错误位置.看起来像这样:

When javac is run directly and prints an error, after the first line of the message, it shows the affected line of source with a caret on the next line pointing to the error position. It looks like this:

com/invariantproperties/udt/sql/RationalUDT.java:324: error: cannot find symbol
    public static boolean lessThan(RRationalUDT p, double q) {
                                   ^
  symbol:   class RRationalUDT
  location: class RationalUDT

请注意直接指向我拼写错误的类型名称的行. maven-compiler-plugin像这样显示它:

Notice the lines that point directly at where I misspelled the type name. The maven-compiler-plugin shows it like this:

[ERROR] /var/tmp/pljava-udt-type-extension/java/src/main/java/com/invariantproperties/udt/sql/RationalUDT.java:[324,36] cannot find symbol
  symbol:   class RRationalUDT
  location: class com.invariantproperties.udt.sql.RationalUDT

注意摆脱了实际指向错误的行. (这是使用Oracle JDK 7.)

Notice it got rid of the line(s) actually pointing to the error. (This is using Oracle JDK 7.)

好吧,所以起初我以为这个较早的问题将得到答案,因为它也是关于maven-compiler-plugin没有显示完整的错误消息,它说此修复程序是要更新到maven-compiler-plugin 3.1版.

Ok, so at first I thought this older question was going to have the answer, because it was also about maven-compiler-plugin not showing the whole error message, and it said the fix was to update to maven-compiler-plugin version 3.1.

但是对于这个问题,我尝试了2.4、3.1和3.5,但没有进行任何改进.总是会显示错误的行.

But for this issue I have tried 2.4, 3.1, and 3.5 without any improvement. The lines displaying the error are always missing.

这适用于任何javac错误.在该示例中,我拼错了一个符号只是为了得到与旧问题所讨论的相同的错误.但是我可以修复该问题,然后再修复一个(该问题来自javac注释处理器):

This applies to any javac error. In the example I misspelled a symbol just to get the same error that the older question was talking about. But I can fix that one and make another one (this one comes from a javac annotation processor):

com/invariantproperties/udt/sql/RationalUDT.java:324: error: No known mapping to an SQL type
    public static boolean lessThan(RationalUDT p, double q) {
                                               ^

,这里再次显示maven-compiler-plugin仅是:

[ERROR] /var/tmp/pljava-udt-type-extension/java/src/main/java/com/invariantproperties/udt/sql/RationalUDT.java:[324,47] error: No known mapping to an SQL type

我的意思是,至少它在括号中显示了行和列,因此并不是完全不可能找到错误,但是javac的正常显示更加有用.有什么方法可以使maven-compiler-plugin不隐藏它?

I mean, at least it shows the line and column in brackets, so it's not totally impossible to find the error, but the normal display from javac is even more helpful. Is there any way to have the maven-compiler-plugin not hide it?

推荐答案

这是不可能的,并且正式的 Maven编译器JIRA

This is not possible and a feature request is already pending on the official Maven Compiler JIRA

在撰写本文时,该票证的状态为 OPEN ,并自7月25日/ 14 创建以来.

The ticket is in status OPEN at the time of writing and created since 25/Jul/14.

您可以提出补丁,也可以-至少-为票证投票(我刚刚做了).

You can either propose a patch or - at least - vote for the ticket (I just did it).

这篇关于如何使Maven-compiler-plugin不隐藏错误源位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 17:39