arturobernalg opened a new pull request, #1191: URL: https://github.com/apache/maven-compiler-plugin/pull/1191
Fixes #661. `AbstractCompilerMojo.execute()` returns early with "No sources to compile" once `compileSourceRoots` is empty, before ever reaching the incremental compilation bookkeeping that normally removes a previous execution's output when its sources go away. So removing all of a module's source directories left `target/classes` (or `test-classes`) exactly as it was after the last build that still had sources, forever - that stale output is only cleared by a later `mvn clean`, not by a plain rebuild. Partial removal (some sources deleted, at least one source root directory still present) already worked correctly through the normal incremental-compile path, which calls `IncrementalBuildHelper` to delete files it recorded as created by the previous execution. This change just reaches that same bookkeeping on the early-return path instead of skipping it, via a new `IncrementalBuildHelper#forgetFilesFromPreviousExecution(File)`. Added a unit test for the new method, and an integration test (`MCOMPILER-443-no-sources-stale-output`) that builds with sources present, then rebuilds with the source directory removed entirely and asserts the previously compiled class is gone - confirmed it fails with the old code (stale class survives) and passes with the fix. Full test suite, checkstyle, spotless and rat pass locally. --- To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) check one of the following: - [x] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) - [x] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
