[MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory by marquiswang · Pull Request #186 · apache/maven-compiler-plugin (original) (raw)

…ctory

The generatedSourcesDirectory (by default target/generated-sources/annotations) contains source code generated by annotation processors. These generated sources are also outputs of the compiler, and thus should be cleaned along with the class files in the outputDirectory, in order to correctly do incremental compilations.

If this isn't done, then javac may not correctly compile the generated code, since it was there before. See https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing

See https://github.com/marquiswang/incremental-compile-dagger-test for a reproducing example.

The bulk of the change here is in maven-shared-incremental, this just passes in the generated-sources directory to the call to the IncrementalBuildHelper.