You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "Vitaliy Sapounov (JIRA)" <ji...@apache.org> on 2013/05/07 10:57:15 UTC

[jira] [Created] (IVY-1422) Dependency "force" does not work if comes from extended module

Vitaliy Sapounov created IVY-1422:
-------------------------------------

             Summary: Dependency "force" does not work if comes from extended module
                 Key: IVY-1422
                 URL: https://issues.apache.org/jira/browse/IVY-1422
             Project: Ivy
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.3.0
            Reporter: Vitaliy Sapounov


***** ENVIRONMENT:

We have a project that uses several Ivy modules:

1) There is a base module that declares dependency on "vendorlib", revision 1.0, with "force" attribute (the whole purpose of the module is to guarantee the "vendorlib" revision):

<ivy-module>
    <info organisation="com.mycompany" module="base" revision="trunk"/>

    <dependencies>
        <dependency org="com.vendor" name="vendorlib" rev="1.0" force="true"/>
    </dependencies>
</ivy-module>


2) There is an extending module that extends the base and includes our library "mylib":

<ivy-module>
    <info organisation="com.mycompany" module="extending" revision="trunk">
        <extends organisation="com.test" module="base" revision="trunk"/>
    </info>

    <dependencies>
        <dependency org="com.mycompany" name="mylib" rev="trunk"/>
    </dependencies>

</ivy-module>

3) Finally, our library "mylib" also depends on "vendorlib", revision 2.0 (i.e. there is another dependency on "vendorlib" with revision 2.0):

<ivy-module>
    <info organisation="com.mycompany" module="mylib" revision="trunk"/>

    <dependencies>
        <dependency org="com.vendor" name="vendorlib" rev="2.0"/>
    </dependencies>

</ivy-module>


4) We use "latest-revision" conflict manager in ivysettings.xml.


***** PROBLEM:

Despite the "force" attribute in base module for "vendorlib", latest revision (2.0) of "vendorlib" is selected by the conflict manager for the extended module.

***** ROOT CAUSE:

LatestConflictManager.java has the following code:

    public Collection resolveConflicts(IvyNode parent, Collection conflicts) {
        if (conflicts.size() < 2) {
            return conflicts;
        }
        for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
            IvyNode node = (IvyNode) iter.next();
            DependencyDescriptor dd = node.getDependencyDescriptor(parent);
            if (dd != null && dd.isForce()
>>>>>>>>>                    && parent.getResolvedId().equals(dd.getParentRevisionId())) {
                return Collections.singleton(node);
            }
        }

Note ">>>>" line: since "vendorlib" with "force" attribute comes from the base module, dd.getParentRevisionId() returns "com.mycompany#base;trunk", but parent.getResolvedId() returns "com.mycompany#extended;trunk", thus the last comparison  returns "false" and "force" is lost.

If we move dependency with "force" to the extended module, it will work.

***** REAL-LIFE APPLICABILITY:

We use the "base" module as a template that fixes versions of libraries provided by the J2EE application server we use. Based on that template, we create a number of extending web applications that guarantee to use the libs that the application server provides. (The actual use case is slightly more complicated, as e.g. "mylib" declares dependency on "vendorlib" version range it supports, e.g. "[2.0,5.7]" range.)


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira