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

Matching of toolchains against version ranges depends on their order of declaration

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Auto Closed
    • 3.2.5
    • None
    • Toolchains
    • None

    Description

      If multiple toolchains of the same type match the requested version range, then the first toolchain in toolchains.xml is selected. This is because the first matching toolchain wins unconditionally, and there is no way nor means to resolve ties. Please see the attached example.

      mvn validate -t toolchains1.xml
      
      [INFO] --- maven-toolchains-plugin:1.1:toolchain (default-toolchain) @ toolchains-test ---
      [INFO] Required toolchain: jdk [ version='[1.7,)' ]
      [INFO] Found matching toolchain for type jdk: JDK[C:/Java/jdk1.8.0_31_x64]
      
      mvn validate -t toolchains2.xml
      
      [INFO] --- maven-toolchains-plugin:1.1:toolchain (default-toolchain) @ toolchains-test ---
      [INFO] Required toolchain: jdk [ version='[1.7,)' ]
      [INFO] Found matching toolchain for type jdk: JDK[C:/Java/jdk1.7.0_76_x64]
      

      I think that a RequirementsMatcher may need two additional features:

      1. order (or priority), so that e.g. a match against 'id' key takes precedence over a match against 'vendor' key. This is specific to the toolchain type and can be provided by toolchain factory at the time of reading the toolchain definition.
      2. comparison for the matched values with the same key, so that e.g. two versions matching the same version range can be compared. We may need some sort of hinting or pluggable strategy here, so that e.g. either the lowest version in the range is preferred, or the highest.

      Then instead of picking the first matching toolchain, Maven would collect all matching toolchains, and then sift through them using the comparison criteria above. If that still results in a tie, then it would either abort the execution, or pick the first toolchain and proceed with it.

      @rfscholte: I saw you've made a lot of changes in the area recently, and maybe you have already considered possible solutions for this particular problem.

      Attachments

        1. toolchains-test.zip
          1 kB
          Sergei Ivanov

        Activity

          People

            Unassigned Unassigned
            sergei_ivanov@mail.ru Sergei S. Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: