Uploaded image for project: 'Ivy'
  1. Ivy
  2. IVY-1606

incorrect dependency order on buildlist

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.5.0-rc1
    • None
    • Core
    • Patch

    Description

      Hi,

      I am facing a problem with the ivy buildlist target: 

      My scenario looks like the graph in picture deps.png (see attachments). 

      The artefact 1B is having a dependency to A in Version 1.0.
      The artefact C is having a dependency to A in Version 2.0 AND a dependency to 1B (in Version 1.0).
      In the ivy.xml file the conflict manager „latest-revision" is active.

      Targets like report and resolve works like a charm, speaking Version 2.0 of artefact A is pulled, while Version 1.0 is evicted. 

      But if I use the ivy:buildlist Tag, the dependency order looks like this:

       

      run:
      [ivy:buildlist] :: Apache Ivy 2.5.0-RC1 - 20141213170938 :: http://ant.apache.org/ivy/ ::
      [ivy:buildlist] :: loading settings :: url = jar:file:/C:/Program%20Files/apache-ant-1.10.1/lib/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
           [echo] ##### buildlist: test#1B, test#A1, test#A, test#D
       
      BUILD SUCCESSFUL
      Total time: 0 seconds
      

       

       

       As you can see, the dependency 1B is in first position, though it has an (evicted) dependency to A.

      After digging around in the source, I found the function getModuleDescriptorDependency in the Class CollectionOfModulesToSort is using a VersionMatcher to determine the correct dependency order.

      So this class do not take the conflict-manager „latest-revision" into account. 

      I workaround this, by patching die SortEngine like so:

       

      27d26
      < import org.apache.ivy.core.module.id.ModuleRevisionId;
      32d30
      < import org.apache.ivy.plugins.version.AbstractVersionMatcher;
      125,137c123
      <         VersionMatcher matcher = new AbstractVersionMatcher("all") {
      <
      <             @Override
      <             public boolean isDynamic(ModuleRevisionId askedMrid) {
      <                 return false;
      <             }
      <
      <             @Override
      <             public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
      <                 return true;
      <             }
      <         };
      <         return matcher;
      ---
      >         return settings.getVersionMatcher();
      

       

       

      After that, in my opinion the build order is correct, as the Version of a dependency should not affect the dependency order:

      run:
      [ivy:buildlist] :: Apache Ivy 2.5.0-CL - 20190826123506 :: http://ant.apache.org/ivy/ ::
      [ivy:buildlist] :: loading settings :: url = jar:file:/C:/Users/kuhnert/.ant/lib/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml
           [echo] ##### buildlist: test#A1, test#A, test#1B, test#D
       
      BUILD SUCCESSFUL
      

       

      If you think, this is the right approach, I can create a merge request for this ticket.
      Otherwise, I would be glad to hear your thoughts.

       

      Kind regards,
      Sven

      Attachments

        1. example.zip
          12 kB
          Sven
        2. deps.png
          8 kB
          Sven

        Issue Links

          Activity

            People

              jaikiran Jaikiran Pai
              Kuhnert Sven
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m