You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Keith Collison <kc...@keithcollison.com> on 2006/11/19 22:19:12 UTC

Help with custom conflict manager

Hello,

Our support libraries are published with the following pattern (note 
these aren't ivy patterns): [module-name]-[version]_[buildnumber].  The 
version number is 2-3 digits -- therefore a typical publication may be 
"core-1.2_34", "core-1.2.1_1", etc.  In each case, the revision label 
registered with Ivy is "1.2_34", "1.2.1_1", and so forth.

The trouble I experienced was that Ivy would consider 1.2_34 to be later 
than 1.2.1_1.  Therefore, 1.2.1_1 would be evicted over 1.2_34.  I 
understood why this was -- Ivy treats the underscore characters as 
periods.  (I cursed the day I agreed to have module versions as "1.2" 
instead of "1.2.0".)

First of all, if you have a way to handle the above scenerio without 
defining a custom latest strategy, let me know.  As it was, I got 
started developing one to handle our version-label strategy.  I 
implemented LatestStrategy in my class.  It differs in one respect from 
the latest-revision strategy -- should it find the pattern (for example) 
1.2_34, it simply inserts the ".0" appropriately (so it ends up 
comparing 1.2.0_34).  My unit tests passed and I was pleased with myself.

The headaches began when I was trying to change our ivy configuration to 
use it.  I've got it registered OK, I've the <latest-strategies> and 
<conflict-managers> nodes defined.  I've a <module> tag, attached to our 
organization, which specifies the custom conflict manager to use.  
Appropriate resolvers have the "latest" attribute pointed to our custom 
strategy.

Despite all of this, Ivy seems to use the default "latest-revision" 
conflict manager to determine which of our modules to evict.  Generating 
the ivy HTML report, nowhere is my conflict manager even referenced.   
The only way I can get my custom conflict manager to work is if I define 
the "defaultLatestStrategy" attribute on the <conf> tag.  It also works 
if I define the defaultConflictManager.  However,  I don't want to 
interfere with 3rd party conflict handling, so I'm hesitant to pursue 
that as a solution.

It just doesn't seem as if the conflict-manager for my <module> is being 
honored.

Am I missing something, or is this a bug in Ivy?   I've included our 
ivyconf below (I've changed some things for proprietary obfuscation, and 
removed property definitions for brevity).

Thanks for your help.

Kind regards,

Keith Collison

<ivyconf>
    <property name="ivy.properties.file.path" 
value="${ivy.conf.dir}/ivyconf-file.properties"
              override="false"/>
    <property name="ivy.default.resolver" value="default" override="false"/>

    <conf defaultCache="${ivy.default.ivy.user.dir}/cache" 
defaultResolver="${ivy.default.resolver}"/>
    <resolvers>
        <chain name="my-chain" latest="my-latest">
                <url name="web-staging">
                    <ivy 
pattern="${my.staging.url}/${my.staging.ivy.pattern}"/>
                    <artifact 
pattern="${my.staging.url}/${my.staging.artifact.pattern}"/>
                </url>
                <url name="web-shared">
                    <ivy 
pattern="${my.shared.url}/${my.shared.ivy.pattern}"/>
                    <artifact 
pattern="${my.shared.url}/${my.shared.artifact.pattern}"/>
                </url>
        </chain>

        <chain name="thirdparty-chain" returnFirst="true">
            <url name="web-thirdparty">
                <ivy 
pattern="${my.thirdparty.url}/${my.thirdparty.ivy.pattern}"/>
                <artifact 
pattern="${my.thirdparty.url}/${my.thirdparty.artifact.pattern}"/>
            </url>
            <ivyrep name="ivyrep"/>
        </chain>
        <chain name="default">
            <resolver ref="thirdparty-chain"/>
        </chain>
    </resolvers>

    <typedef name="my-latest-strategy" classname="com.mylatest.MyLatest"/>
    <latest-strategies>
        <my-latest-strategy name="my-latest"/>

    </latest-strategies>
    <conflict-managers>
        <latest-cm name="my-revision" latest="my-latest"/>
    </conflict-managers>

    <modules>
        <module organisation="myorganization" matcher="regexp" 
conflict-manager="my-revision" name=".*" resolver="my-chain"/>
    </modules>
</ivyconf>




Re: Help with custom conflict manager

Posted by Xavier Hanin <xa...@gmail.com>.
On 11/19/06, Keith Collison <kc...@keithcollison.com> wrote:
>
> Hello,
>
> Our support libraries are published with the following pattern (note
> these aren't ivy patterns): [module-name]-[version]_[buildnumber].  The
> version number is 2-3 digits -- therefore a typical publication may be
> "core-1.2_34", "core-1.2.1_1", etc.  In each case, the revision label
> registered with Ivy is "1.2_34", "1.2.1_1", and so forth.
>
> The trouble I experienced was that Ivy would consider 1.2_34 to be later
> than 1.2.1_1.  Therefore, 1.2.1_1 would be evicted over 1.2_34.  I
> understood why this was -- Ivy treats the underscore characters as
> periods.  (I cursed the day I agreed to have module versions as "1.2"
> instead of "1.2.0".)
>
> First of all, if you have a way to handle the above scenerio without
> defining a custom latest strategy, let me know.  As it was, I got
> started developing one to handle our version-label strategy.  I
> implemented LatestStrategy in my class.  It differs in one respect from
> the latest-revision strategy -- should it find the pattern (for example)
> 1.2_34, it simply inserts the ".0" appropriately (so it ends up
> comparing 1.2.0_34).  My unit tests passed and I was pleased with myself.
>
> The headaches began when I was trying to change our ivy configuration to
> use it.  I've got it registered OK, I've the <latest-strategies> and
> <conflict-managers> nodes defined.  I've a <module> tag, attached to our
> organization, which specifies the custom conflict manager to use.
> Appropriate resolvers have the "latest" attribute pointed to our custom
> strategy.
>
> Despite all of this, Ivy seems to use the default "latest-revision"
> conflict manager to determine which of our modules to evict.  Generating
> the ivy HTML report, nowhere is my conflict manager even referenced.
> The only way I can get my custom conflict manager to work is if I define
> the "defaultLatestStrategy" attribute on the <conf> tag.  It also works
> if I define the defaultConflictManager.  However,  I don't want to
> interfere with 3rd party conflict handling, so I'm hesitant to pursue
> that as a solution.
>
> It just doesn't seem as if the conflict-manager for my <module> is being
> honored.
>
> Am I missing something, or is this a bug in Ivy?   I've included our
> ivyconf below (I've changed some things for proprietary obfuscation, and
> removed property definitions for brevity).
>
> Thanks for your help.
>
> Kind regards,
>
> Keith Collison
>
> <ivyconf>
>     <property name="ivy.properties.file.path"
> value="${ivy.conf.dir}/ivyconf-file.properties"
>               override="false"/>
>     <property name="ivy.default.resolver" value="default"
> override="false"/>
>
>     <conf defaultCache="${ivy.default.ivy.user.dir}/cache"
> defaultResolver="${ivy.default.resolver}"/>
>     <resolvers>
>         <chain name="my-chain" latest="my-latest">
>                 <url name="web-staging">
>                     <ivy
> pattern="${my.staging.url}/${my.staging.ivy.pattern}"/>
>                     <artifact
> pattern="${my.staging.url}/${my.staging.artifact.pattern}"/>
>                 </url>
>                 <url name="web-shared">
>                     <ivy
> pattern="${my.shared.url}/${my.shared.ivy.pattern}"/>
>                     <artifact
> pattern="${my.shared.url}/${my.shared.artifact.pattern}"/>
>                 </url>
>         </chain>
>
>         <chain name="thirdparty-chain" returnFirst="true">
>             <url name="web-thirdparty">
>                 <ivy
> pattern="${my.thirdparty.url}/${my.thirdparty.ivy.pattern}"/>
>                 <artifact
> pattern="${my.thirdparty.url}/${my.thirdparty.artifact.pattern}"/>
>             </url>
>             <ivyrep name="ivyrep"/>
>         </chain>
>         <chain name="default">
>             <resolver ref="thirdparty-chain"/>
>         </chain>
>     </resolvers>
>
>     <typedef name="my-latest-strategy" classname="com.mylatest.MyLatest"/>
>     <latest-strategies>
>         <my-latest-strategy name="my-latest"/>
>
>     </latest-strategies>
>     <conflict-managers>
>         <latest-cm name="my-revision" latest="my-latest"/>
>     </conflict-managers>
>
>     <modules>
>         <module organisation="myorganization" matcher="regexp"
> conflict-manager="my-revision" name=".*" resolver="my-chain"/>
>     </modules>
> </ivyconf>


Hi,

First I'd like to clarify the difference between conflict manager and latest
strategy roles. A conflict manager is used only when there is a conflict
between two revisions (for instance A depends on C 1.2 and B depends on C
1.3), while latest strategy is used when you have a dependency using a
dynamic version (like latest.integration). In this case it is not considered
as a conflict, and thus only the latest strategy is used.
So in your case you configure a conflict manager using your latest strategy,
this is ok. The problem seems to be due to the fact that the latest strategy
is not used. Why isn't it used? The latest strategy defined on the chain
should be applied to all resolvers of the chain, but it was bugged in a
previous version of Ivy (fixed in 1.4 if I remember well). So if you use an
old version of Ivy, try with a 1.4.1. If you still have the problem, then to
find what is the problem I suggest to put debug information on and track
everything related to latest strategy management, and see if you can better
understand what's happening (and post a message with your log attached here
if you want us to investigate more).

Xavier