问题
Maybe there is a maven-compiler-plugin
option for this, but I haven't found it.
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
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
Notice it got rid of the line(s) actually pointing to the error. (This is using Oracle JDK 7.)
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.
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.
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) {
^
and here again what the maven-compiler-plugin
shows is only:
[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
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?
回答1:
This is not possible and a feature request is already pending on the official Maven Compiler JIRA
MCOMPILER-229: Compilation error should be reported as by javac tool
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).
来源:https://stackoverflow.com/questions/35256796/how-to-make-maven-compiler-plugin-not-hide-error-source-locations