Is there a way to separate Java annotation processing errors from other compilation errors?

72 Views Asked by At

I have a maven module with 1000+ Java source files. Some of these have annotations that are processed via processors Dagger and Immutables, each of which generates code. When I have an error in a Dagger or Immutables annotated file, the annotation processor fails to complete. The resulting build errors contain the "real" error that triggered the processor to fail, as well as lots of errors complaining about not being able to find the generated code, e.g. 137 errors in my current example. Browsing all such errors to find the "real" error is tedious.

Is there a way to separate the annotation-processing error from the other errors that result from it failing to generate code?

I have tried both proc:none and proc:only as javac arguments, but neither seems to make any difference.

In case it helps, here is the part of pom.xml for compilation

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    <compilerArgs>
                        <arg>-proc:only</arg>
                        <arg>-verbose</arg>
                        <arg>-Xmaxerrs</arg>
                        <arg>1000</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

I have tried with and without -proc:only and -proc:none. Note that the -Xmaxerrs 1000 is needed as the default seems to be 100, for me at least.

1

There are 1 best solutions below

2
Graeme Moss On

Till I get a better answer (if one is possible) my strategy so far (as suggested by "@Matteo NNZ") is to output the build log to a file and then exclude the most common issue resulting from failing to generate code "cannot find symbol", e.g.

$ grep "^\[ERROR\] /" output.txt | grep -v "cannot find symbol"

Note that setting something like -Xmaxerrs 1000 is critical here to ensure the "real" error is not missed.