Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5039

Maven does not properly track class files to be included in jar/test breaking incremental build

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 2.2.1, 3.0
    • None
    • Plugins and Lifecycle
    • None

    Description

      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
      cd java-build-test
      sh runme.sh

      (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.

      Attachments

        Issue Links

          Activity

            People

              bentmann Benjamin Bentmann
              emilsit Emil Sit
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: