Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make maven-compiler-plugin not hide error source locations

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?

like image 602
Chapman Flack Avatar asked Feb 07 '16 17:02

Chapman Flack


People also ask

How do I change my default Maven compiler?

Show activity on this post. Create a pom-only ( <packaging>pom</packaging> ) project that has the compiler settings (and any other default settings) you want. You give treat it like any other project (release it; deploy it to your Maven repo, etc.). It doesn't help much if all you want to set is compiler settings.

Does Maven require compiler plugin?

Maven Compiler Plugin might be the most important plugin in Maven. It is used to compile the sources of your project, which transform Java files ( *.

Is Maven compiler plugin required with spring boot?

Technically we can use both spring-boot-maven-plugin and maven-compiler-plugin in combination if the requirement is to create an executable jar as well as make sure source and target code have a specific version (which is accomplished by including maven-compiler-plugin).

What is Maven compiler plugin and Target?

The compiler plugin is used to compile the source code of a Maven project. This plugin has two goals, which are already bound to specific phases of the default lifecycle: compile – compile main source files. testCompile – compile test source files.


1 Answers

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).

like image 172
A_Di-Matteo Avatar answered Oct 11 '22 12:10

A_Di-Matteo