You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Xavier Hanin <xa...@gmail.com> on 2008/09/01 08:43:48 UTC

Re: OSGi friendly LatestRevisionStrategy patch

On Sun, Aug 31, 2008 at 6:16 PM, Alex Radeski <al...@radeski.net> wrote:

> Hi,

Hi Alex,


>
>
> While working on the Bushel project (http://code.google.com/p/bushel/)
> to add OSGi bundle support to Ivy, I stumbled across a limitation in
> the LatestRevisionStrategy. The current implementation sorts OSGi
> major.minor.micro[.qualifier] in what I think is the wrong order.
>
> For example, from the LatestRevisionStrategyTest.testComparator()
> test, the natural order of both OSGi and non-OSGi versions is:
>    0.2a, 0.2_b, 0.2rc1, 0.2-final, 1.0-dev1, 1.0-dev2, 1.0-alpha1,
> 1.0-alpha2, 1.0-beta1, 1.0-beta2, 1.0-gamma, 1.0-rc1, 1.0-rc2, 1.0,
> 1.0.1, 2.0, 2.0.0, 2.0.0.b006, 2.0.0.b012, 2.0.0.xyz
>
> However, the current implementation produces the following, where the
> last four elements are in the wrong order:
>    0.2a, 0.2_b, 0.2rc1, 0.2-final, 1.0-dev1, 1.0-dev2, 1.0-alpha1,
> 1.0-alpha2, 1.0-beta1, 1.0-beta2, 1.0-gamma, 1.0-rc1, 1.0-rc2, 1.0,
> 1.0.1, 2.0, 2.0.0.b006, 2.0.0.b012, 2.0.0.xyz, 2.0.0
>
> This is because it currently gives equal weighting to the [._-+]
> characters, instead of giving the '.' character precedence.

While I understand the your point of view, the change you request may imply
breaking versionning strategies for people using for years. Hence I'm not in
favor of changing this, at least we need to provide an easy to use backward
compatible version of this strategy.


> I have
> attached a patch the fixes this limitation, as well as updating the
> unit test. I have also fixed a minor bug in the test where it assumed
> the versions were shuffled, but they weren't.
>
> The current way to work around this is to override all the
> latest-strategies in the ivysettings.xml, which I'd like to avoid if
> possible. For example:
>
> <ivysettings>
>    <classpath file="${basedir}/lib/bushel-0.6.1.jar" />
>
>    <typedef name="osgi-parser"
> classname="com.googlecode.bushel.ivy.OsgiManifestParser" />
>    <typedef name="osgi-file"
> classname="com.googlecode.bushel.ivy.OsgiFileResolver" />
>    <typedef name="osgi-latest"
> classname="com.googlecode.bushel.ivy.OsgiLatestStrategy" />
>
>    <settings defaultLatestStrategy="osgi-latest-revision" />
>    ...
>    <resolvers>
>        <osgi-file name="local-rcp-repo" latest="osgi-latest-revision">
>        ...
>        </osgi-file>
>    </resolvers>
>
>    <latest-strategies>
>        <osgi-latest name="osgi-latest-revision" />
>    </latest-strategies>
> </ivysettings>

Once you have defined the defaultLatestStrategy, you shouldn't have to
specify it everywhere. If you have to, it's a bug, please report it with a
JIRA.


>
> I hope you can use this patch.

As I said, I don't think we can use it like this. But maybe we could find a
way for the latest revision strategy to behave as you want or as before. It
could be an attribute, which value could be set either directly, or through
an Ivy variable. Then switching to OSGi mode would only require setting one
variable, instead of what you do now.

What do you and others think about that?

Xavier

>
>
> Cheers,
> Alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>



-- 
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://ant.apache.org/ivy/
http://www.xoocode.org/

Re: OSGi friendly LatestRevisionStrategy patch

Posted by Alex Radeski <al...@radeski.net>.
On Mon, Sep 1, 2008 at 7:43 AM, Xavier Hanin <xa...@gmail.com> wrote:

Hi Xavier,

> While I understand the your point of view, the change you request may imply
> breaking versionning strategies for people using for years. Hence I'm not in
> favor of changing this, at least we need to provide an easy to use backward
> compatible version of this strategy.

That's a fair point, I wouldn't want to break backward compatibility.I
should explain that I appended the OSGi-like versions to the unit test
in my previous post, i probably should have created a separate unit
test. So the old test still passes with the new implementation, hence
still backward compatible.

>
> Once you have defined the defaultLatestStrategy, you shouldn't have to
> specify it everywhere. If you have to, it's a bug, please report it with a
> JIRA.

Ok, I'll double check this was an issue.

> As I said, I don't think we can use it like this. But maybe we could find a
> way for the latest revision strategy to behave as you want or as before. It
> could be an attribute, which value could be set either directly, or through
> an Ivy variable. Then switching to OSGi mode would only require setting one
> variable, instead of what you do now.
>
> What do you and others think about that?

I think what you say is pretty fair. Rather than patching the
LatestReviStrategy class, we could provide a separate OSGi-friendly
class.

Alex.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org