Marquis Wang created MCOMPILER-532: -------------------------------------- Summary: compile doesn't work without first clean with Dagger annotation processor Key: MCOMPILER-532 URL: https://issues.apache.org/jira/browse/MCOMPILER-532 Project: Maven Compiler Plugin Issue Type: Bug Reporter: Marquis Wang
I have a reproducing example here: https://github.com/marquiswang/incremental-compile-dagger-test. The README there shows how it goes wrong. Long story short, if you use mvn compile on a project with Dagger, touch the @Injected files, then do mvn compile again, then it will not correctly compile the Dagger-generated factory methods. You need to do a mvn clean compile. I am pretty sure that this is because of how maven-compiler-plugin and javac interact with Dagger. maven-compiler-plugin will, if it detects that a file has changed, delete compiled class files and recompile every class in the module. However, it does not delete target/generated-sources/annotations/. It calls javac on the Foo.java. Dagger chooses not to re-generate the Foo_Factory.java file, presumably because it already exists. javac detects that no new files were created by annotation processing, so it doesn't compile anything. According to https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing , javac only compiles "newly generated source files", so it doesn't compile the existing Foo_Factory.java. I think the solution is, when maven-compiler-plugin detects that sources have changed it and it needs to re-compile, it should delete target/generated-sources/annotations as well as target/classes before compiling. -- This message was sent by Atlassian Jira (v8.20.10#820010)