Rolf W.
Rolf W.

Reputation: 1409

Javac not running annotation processors

Problem

I'm revisiting a maven project that I haven't touched in at least a year. I'm pretty sure it was compiling successfully when I left it (there was still a working jar in the target directory), but now compilation fails because generated classes are missing.

What I tried

Possible factors

Command options

This is the javac command I'm currently using:

javac -d ./target/classes -classpath ./target/classes:$HOME/.m2/repository/com/google/dagger/dagger/2.4/dagger-2.4.jar:$HOME/.m2/repository/com/google/dagger/dagger-compiler/2.4/dagger-compiler-2.4.jar:$HOME/.m2/repository/com/google/auto/factory/auto-factory/1.0-beta3/auto-factory-1.0-beta3.jar:$HOME/.m2/repository/org/immutables/builder/2.3.9/builder-2.3.9.jar:$HOME/.m2/repository/org/immutables/value/2.3.9/value-2.3.9.jar:<LONG LIST OF DIRECT AND TRANSITIVE DEPENDENCIES HERE> -sourcepath ./src/main/java: -s ./target/generated-sources/annotations -verbose -XprintRounds -XprintProcessorInfo -Xlint -J-verbose -processor org.immutables.processor.ProxyProcessor -proc:only ./src/main/java/com/mycompany/myproject/Main.java

NOTE: for better readability, I put each argument on a new line, replaced absolute paths with $HOME/ and ./ and I omitted most dependencies.

Question

What am I missing here? Any suggestions or pointers would be greatly appreciated.

Upvotes: 6

Views: 4305

Answers (3)

mjaggard
mjaggard

Reputation: 2477

javac appears to completely and silently skip annotation processing for some parse failures.

For me a duplicated annotation caused by a merge mistake caused thousands of failures because my annotation processors didn't run - so the real error got completely lost.

@Data @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode(callSuper = false)
@EqualsAndHashCode(callSuper = false)

Upvotes: 4

Gerrit Brouwer
Gerrit Brouwer

Reputation: 750

We had the same issue on a git branch, while the main branch built fine. The root cause turned out to be a .java source with a duplicate definition of a private void function. This duplicate was caused by a merge from the main branch. At first we did not notice it, because the merge did not cause conflicts. The problem occurred with Amazon Corretto 8 and 11 compilers. After removing the duplicate private void function, the java compiler started generating sources as before.

Upvotes: 0

Daniel
Daniel

Reputation: 1594

As far as I can remember maven generates a marker file or marker directory (starting with a dot) for generated sources. But it's also a long time ago...

Upvotes: 0

Related Questions