ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Sweeney <tony.swee...@springsource.com>
Subject Re: OSGi friendly LatestRevisionStrategy patch
Date Mon, 01 Sep 2008 09:31:43 GMT

On Aug 31, 2008, at 5:16 PM, Alex Radeski wrote:

> Hi,
>
> 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

Note that several of your examples are not valid OSGi revision  
numbers.  The syntax for OSGi is "major[.minor[.micro[.qualifier]]]"  
where major, minor and micro can only be numeric, and qualifier is the  
only part of a version number which can contain alphanumeric  
characters, from the character range [a-zA-Z0-9], '_' and '-'.  If the  
minor or micro number is absent it should sort as 0 (i.e. 2.1 ==  
2.1.0), and the sort order of qualifier is a natural alphabetical  
sort.  You can only have a qualifier if you have all three numeric  
components, so only the versions from 1.0 onwards in your list are  
valid.

>
>
> 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

2.0.0 should sort with 2.0 before all of the 2.0.0 versions with a  
qualifier, so if your patch fixes that then it's an improvement.

>
>
> This is because it currently gives equal weighting to the [._-+]
> characters, instead of giving the '.' character precedence. 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>
>
> I hope you can use this patch.
>
> Cheers,
> Alex
> <osgi-friendly-latest-rev-strategy- 
> aradeski 
> .patch 
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org


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


Mime
View raw message