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

Dynamic version resolution result is incorrect when ivy metadata contains extra attributes.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.2.0
    • 2.3.0-RC1
    • Core
    • None

    Description

      Ivy resolution is incorrect given the following configuration:

      ivy metadata of logging#slf4j;1.6.1
      <ivy-module version="2.0" xmlns:extra="http://ant.apache.org/ivy/extra">
      <info organisation="logging" module="slf4j" revision="1.6.1" extra:tag="logging">
      <description>Front end logging API.</description>
      </info>
      <configurations>
      <conf name="runtime" description="Core runtime dependencies"/>
      <conf name="jcl-bridge" extends="runtime" description="Jakarta Commons Logging Bridge dependencies"/>
      <conf name="jul-bridge" extends="runtime" description="Java Util Logging Bridge dependencies"/>
      <conf name="log4j-bridge" extends="runtime" description="Apache Log4J Bridge dependencies"/>
      <conf name="bridges" extends="jcl-bridge,jul-bridge,log4j-bridge" description="Groups all logging bridge dependencies"/>
      </configurations>
      <publications>
      <artifact name="slf4j-api-1.6.1" type="jar" ext="jar" conf="runtime"/>
      <artifact name="jcl-over-slf4j-1.6.1" type="jar" ext="jar" conf="jcl-bridge"/>
      <artifact name="jul-to-slf4j-1.6.1" type="jar" ext="jar" conf="jul-bridge"/>
      <artifact name="log4j-over-slf4j-1.6.1" type="jar" ext="jar" conf="log4j-bridge"/>
      </publications>
      </ivy-module>

      ivy metadata of logging#logback;0.9.24 ivy:
      <ivy-module version="2.0">
      <info organisation="logging" module="logback" revision="0.9.24">
      <description>Back end logging implementation that implements SLF4J (successor to Log4J).</description>
      </info>
      <configurations>
      <conf name="runtime" description="Core runtime dependencies"/>
      </configurations>
      <publications>
      <artifact name="logback-core-0.9.24" type="jar" ext="jar" conf="runtime"/>
      <artifact name="logback-classic-0.9.24" type="jar" ext="jar" conf="runtime"/>
      </publications>
      <dependencies>
      <dependency org="logging" name="slf4j" rev="1.6.1" conf="runtime->bridges"/>
      </dependencies>
      </ivy-module>

      Dependencies to resolve:
      <dependency org="logging" name="slf4j" rev="[1.6.1, 1.6.2]" conf="runtime"/>
      <dependency org="logging" name="logback" rev="[0.9.24, 0.9.25]" conf="build-tests->runtime" />

      I would expect the following jars of slf4j are resolved:
      slf4-api-1.6.1.jar, jcl-over-slf4j-1.6.1.jar, jul-to-slf4j-1.6.1.jar, log4j-over-slf4j-1.6.1.jar
      However, only slf4j-api-1.6.1.jar is resolved.

      A eclipse project is attached to demonstrate the issue.
      ivy metadata for slf4j 1.6.1: repo\logging\slf4j\1.6.1\ivy.xml)
      ivy metadata for logback 0.9.24: repo\logging\logback\0.9.24\ivy.xml

      I've debugged through and found that VisitNode does not deal with dynamic version correctly, so that when slf4j contains extra attributes, it behaves incorrectly:
      org.apache.ivy.core.resolve.VisitNode: line 286 - 302
      public boolean loadData(String conf, boolean shouldBePublic) {
      boolean loaded = node.loadData(
      rootModuleConf, getParentNode(), parentConf, conf, shouldBePublic, getUsage());
      if (loaded) {
      useRealNode();
      // if the loaded revision is different from original one
      // we now register this node on the new resolved id
      // this includes two cases:
      // - the id refers to a dynamic revision, which has beenresolved by loadData
      // - the loaded module descriptor has extra attributes in his info tag which are not
      // used when declaring the dependency
      if (data.getNode(node.getResolvedId()) == null || !data.getNode(node.getResolvedId()).getId().equals(node.getResolvedId()))
      {
      data.register(node.getResolvedId(), this);

      /** If node's id is dynamic, e.g. logging#slf4j;[1.6.1, 1.6.2], then the VisitNode will not be associated with it because only resolvedId is considered here*/
      /** The following fix associates dynamic id with VisitData as well */
      /** FIX START **/
      if(!node.getResolvedId().equals(node.getId()))

      { ModuleRevisionId resolvedId = node.getResolvedId(); data.register(ModuleRevisionId.newInstance(resolvedId.getOrganisation(), resolvedId.getName(), resolvedId.getBranch(), resolvedId.getRevision()), this); }

      /** FIX END **/
      }
      }

      return loaded;
      }

      I've applied this fix to handle dynamic version and then the resolution works fine.

      Thanks,
      Tom

      Attachments

        1. dynamic_version_bug.zip
          4 kB
          Tom Liu

        Activity

          People

            maartenc Maarten Coene
            liulitom Tom Liu
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: