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

Maven version ranges do not properly handle versions with more than four components



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 3.0.4
    • Fix Version/s: None
    • Component/s: General
    • Labels:
    • Environment:
      Linux 64-bit


      When using a version range, e.g. "[1.0-SNAPSHOT,)", versions with more than four components are not sorted correctly. For example, "" will be sorted as greater/later than "". However, "1.0.0" will be sorted as greater/later than "".

      The behavior here is a bit odd... all of the maven-metadata-XXX.xml files in the local repository will correctly list "" as the "latest" and "release" version, but running compile, dependency:tree, etc. will instead select "". Aether API calls are also exhibiting the buggy sorting behavior, too.

      I haven't yet tried any debugging to track this down, but I've trolled through git and my best guess is that this behavior is related to the version of maven-artifact being used. The 2.x releases DefaultArtifactVersion.compareTo(...) method does not correctly handle versions with more than four components, but the 3.x releases of it do [1]. Maybe the problem is just that the compile plugin is still using maven-artifact:2.0.9?

      This is hurting us here. While many of our projects use versions with four or less components, we follow the add a version component for branches versioning strategy to prevent version conflicts between branches. This allows us to use version ranges in our POMs, making life a lot easier.

      [1] The following commit seems to be where this was fixed in maven-artifact: maven.git beb9d731691beed1b0099a790a8ae1973f55dc0b. It looks like the code is what was originally proposed in the Improve default support for version schemes Maven wiki page.




            • Assignee:
              karlmdavis Karl M. Davis
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: