Maven
  1. Maven
  2. MNG-5039

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

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Duplicate
    • Affects Version/s: 2.2.1, 3.0
    • Fix Version/s: None
    • Component/s: Plugins and Lifecycle
    • Labels:
      None
    • Complexity:
      Intermediate
    • Testcase included:
      yes
    • Number of attachments :
      0

      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.

        Issue Links

          Activity

          Benjamin Bentmann made changes -
          Field Original Value New Value
          Link This issue duplicates MNG-4885 [ MNG-4885 ]
          Benjamin Bentmann made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Assignee Benjamin Bentmann [ bentmann ]
          Resolution Duplicate [ 3 ]
          Benjamin Bentmann made changes -
          Component/s Plugins and Lifecycle [ 11340 ]
          Component/s Bootstrap & Build [ 11865 ]
          Hide
          Emil Sit added a comment -

          This strikes me to be a different problem from MNG-4885. It's one thing for incremental builds to be efficient (as in only recompiling the files that need to be recompiled). It's another thing entirely to include class files that shouldn't be included in jar/war artifacts and in test runners, after they've been compiled.

          Show
          Emil Sit added a comment - This strikes me to be a different problem from MNG-4885 . It's one thing for incremental builds to be efficient (as in only recompiling the files that need to be recompiled). It's another thing entirely to include class files that shouldn't be included in jar/war artifacts and in test runners, after they've been compiled.
          Hide
          Benjamin Bentmann added a comment -

          It's just another facet of the same feature.

          Show
          Benjamin Bentmann added a comment - It's just another facet of the same feature.

            People

            • Assignee:
              Benjamin Bentmann
              Reporter:
              Emil Sit
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: