Affects Version/s: 2.2.1, 3.0
Fix Version/s: None
Component/s: Plugins and Lifecycle
Number of attachments :
When files in the source tree (either src/main or src/test) are renamed or removed, the class files resulting from their prior compilation remain in the corresponding target/ directories. It seems that surefire and package plugins simply grab everything from target/ and as a result, incremental builds are not correct. For example,
- If you remove a test source file and the test will continue to run. This is bad esp when the test is failing; packaging will fail even though it should not.
- If you remove/rename a source file and the class file will continue to be in the jar. This may cause tests to succeed even though they should not. (And if you share the jar, this will affect downstream non-test dependencies.)
I wrote up a test suite for the second case and put it up at https://github.com/sit/java-build-test. To run it ...
git clone git://github.com/sit/java-build-test.git
(It does rely on git to automate the rename/delete actions though so a tar of the sources won't work.)
In addition to Maven, it tests Gradle (which works) and Buildr (which behaves the same as Maven).
While incremental builds are not the recommendation for official deliverables, this does make Maven appear extremely unreliable to developers who never know after syncing whether they will have to do a clean build or if an incremental one is correct.