Skip to main content
Jump to: navigation, search

Equinox/p2/Omni Version

< Equinox‎ | p2
Revision as of 05:51, 22 December 2008 by Thomas.tada.se (Talk | contribs) (Named Version Formats)

W.I.P - Reworked proposal after discussion Dec 15, 2008 - Not Ready for review. DO NOT EDIT - EDITS ARE CURRENTLY MADE OFFLINE

Summary of changes:

  • Previous proposal alllowed multiple implementations of Version and VersionRange. The new proposal is to only support a single implementation.
  • The 'any' format has been removed
  • The 'raw' format has been change to the new name 'format', and 'raw' is now used to describe a canonical version
  • The pattern language have been made more powerful - since new version types can not be plugged in
  • A proposal how to handle sharing of named patterns has been added
  • An FAQ has been added at the end, answering some of the questions asked by reviewers

Introduction

This page describes a proposal for adding support for non OSGi version and version ranges in Equinox p2. This page was created as a result of the discussion on the p2 call on Dec 1, 2008. See bug 233699 for discussion.

Background

There are other versioning schemes in wide use that are not compatible with OSGi version and version ranges. The problem is both syntactic and semantic.

Example of semantic issues

Many open source projects do their versioning in a fashion similar to OSGi but with one very significant difference. For two versions that are otherwise equal, a lack of qualifier signifies a higher version then when a qualifier is present. I.e.

1.0.0.alpha 
1.0.0.beta
1.0.0.rc1
1.0.0

The 1.0.0 is the final release. The qualifier happens to be in alphabetical order here but that's not always true.

Mozilla Toolkit versioning has many rules and where each segment has 4 (optional slots; numeric, string, numeric, and string where each slot has a default value of being 0 or "max string" if missing).

1.2a3b.  // yes, a trailing . is allowed and means .0
1.a2

Mozilla also allows bumping the version (using an older Mozilla scheme)

1.0+ 

This means 1.1pre in mozilla.

Example of syntax issue

Here are some examples of versions used in Red Had Fedora distributions.

KDE Admin version 7:4.0.3-3.fc9
Compat libstdc version 33-3.2.3-63
Automake 1.4p6-15.fc7

And here are some mozilla toolkit versions:

1.*.1
1.0+
1.-1  // yes, negative integer version numbers are allowed, the - is not a delimiter
1.2a3b.a

These are not syntactically compatible with OSGi versions.

Current implementation in p2

The current implementation in p2 uses the classes Version and VersionRange to describe the two concepts and these are implementations handling only OSGi version type.

Proposed Solution

One implementation of Version and VersionRange

Equinox p2 should have one implementation of Version and one of VersionRange (called OmniVersion, and OmniVersionRange in this proposal just to give these implementation different names) capable of capturing the semantics of various version formats. The advantages over previous proposal are that there is no need to dynamically plugin new implementations, and new formats can be more easily be introduced.

Even if the finished solution only requires a single implementation (the OmniVersion discussed below), there are other factors to consider. The current p2 SimplePlanner uses the OSGi planner, and it can only understand OSGi versions. There is work being done on SAT4J to enable it being used instead of the OSGi planner (work to handle "explanations" could also be used to handle "attachments" (now being done with OSGi planner).

See bug 233699 for more information. A patch is now proposed that has the p2 Version and VersionRange classes broken out, and where these are translated to OSGI version and version range where needed.

With this patch it is possible to replace the p2 Version and VersionRange with the Omni implementation and replace SimplePlanner's use of OSGi planner with a similar planner that handles OmniVersion. This can be done by someone that needs support for different versions formats before the SAT4j solution is available.

One Canonical Format

The OmniVersion and OmniVersion range should be "universal" - all instances of Version should be comparable against each other with a fully defined (non ambiguous) ordering. The API could (as today) be based on a single string fully describing a version or version range, or use a structured approach to describe the canonical, original, and transformation rule in separate strings. In both cases, having string representation in the API is probably the best.

This proposal is based on the assumption that a single string is used.

The canonical string format is called "raw" and it is explained in more detail below. To ensure backwards compatibility, as well as providing ease of use in an osgi environment, version strings that are not prefixed with the keyword "raw" have the same format and semantics as the current osgi version format.

Ad an example the following two version strings are both valid input, and express exactly the same version:

1.0.0.r1234
raw:1.0.0.'r1234'

Implementation of Omni Version and VersionRange

An implementation is being developed in parallell with this specification.

OmniVersion

The OmniVersion implementation uses an Object Array to store version-segements in order of descending significance. A segment is an instance of Integer, String, Comparable[], MaxInteger, MaxString, or Pad. A Pad instance has a reference to one version segment used as padding. Pad can only be placed last in a version segment array.

Comparison

Comparison is done by iterating over segments from 0 to n.

  • If a segment is a pad segment, the referenced version segment is used in the comparison.
  • If segments are of different type the rule MaxInteger > Integer > Comparable[] > MaxString > String is used - the comparison is done and the version with the greater segment type is reported as greater.
  • If segments are of equal type - they are compared - if one is greater the comparison is done and the version with the greater segment is reported as greater.
  • If the shorter of two versions has a pad segment, the extra segments in the longer version are compared against this pad segment.
  • If all segments are equal up to end of the shortest segment array, the longer version is reported as greater.
  • As a consequence of not including delimiters in the canonical format; two versions are equal if they only differ on delimiters.

Raw and Original Version String

The original version should be kept when the raw version format is used, but it is not an absolute requirement as simple raw based forms such as raw:1.2.3.4.5 could certainly be used by humans. Someone (who for some reason does not want to use osgi or some other version scheme), could elect to use the raw format as their native format.

A version string with raw and original is written on the form:

  'raw' ':' raw-format-string '/' original-format-string

The p2 Engine completely ignores the original part - only the raw part is used, and the original format is only used for human consumption.

Example using a mozilla version string (as it has the most complex format encountered to date).

  raw:{1.m.0.m}.{20.'a'.3.'b'}p{0.m.0.m}/1.20a3b.a

See below for full explanation of the raw format.

OmniVersionRange

The OmniVersionRange holds two OmniVersion instances (lower and upper bound). A version range string uses the delimiters '[]', '()' and ','. If these characters are used in the lower or upper bound version strings, these occurrences must be escaped with '\' and occurrences of '\' must also be escaped.

The version range is either an osgi version range (if raw prefix is not used), or a raw range. The format of the raw range is:

  'raw' ':' ( '[' | '(' ) raw-format-string ',' raw-format-string ( ']' | ')' ) 

The raw-range can be followed by the original range:

  raw-range '/' ( '[' | '(' ) original-format-string ',' original-format-string ( ']' | ')' )

The p2 Engine completely ignores the original part - only the raw part is used, and the original format is only used for human consumption.

See below for full explanation of the raw format.

Note that some version schemes have range concepts where the notion of inclusive or exclusive does not exist, and instead use symbolic markers such as "next larger", "next smaller", or use wildcards to define ranges. In these cases, the publisher of an IU must use discrete versions and the inclusive/exclusive notation to define the same range.

Version Formats

There are two basic formats default osgi string format, and raw canonical string format.

The following definitions are common to all the definitions below:

  digit: [0-9];
  letter: [a-zA-Z];
  numeric : digit+;
  alpha : letter+;
  alpha-numeric : [0-9a-zA-Z]+;
  delimiter: [^0-9a-zA-Z];
  character: .;
  characters .+
  quoted-string: ("[^"]*")|('[^']*')  // i.e a sequence of charactes quoted with " or ', where ' can be used in a " quoted string and vice versa
  sq: ['];
  dq: ["];
format string description
A version string that starts with a digit is an OSGi version string. It is backwards compatible. The input string "1.0.0r1234" is an example of an osgi version string.
raw The raw format is a string representation of the internally used format - it consists of the keyword "raw", followed by a list of entries separated by period.

An entry can be numerical, quoted alphanumerical, or a sub canonical list on the same format. A canonical version (and sub canoncial version arrays) can be padded to infinity with a special padding element. Special entries express the notion of 'max integer' and 'max string'.

The raw canonical form has the following format:

    raw-format :
      | 'raw' ':' raw-elements [ pad-element ] 
      ;
    raw-elements :
      | raw-elements '.' raw-element
      | raw-element
      ;
   raw-element :
      | numeric
      | quoted-strings  // strings are concatenated
      | '{' raw-elements [ pad-element ] '}'   // subvector of elements
      | 'm'   // symbolic 'maxs' == max string
      | 'M'   // symbolic 'max' i.e. max > maxs
      ;
   quoted-strings :
     | quoted-strings quoted-string
     | quoted-string
     ;
   pad-element :
     | 'p' raw-element
     ;

Examples:

  • OSGi 1.0.0.r1234 is expressed as raw:1.0.0.'r1234'
  • apache/triplet style 1.2.3 is expressed as raw:1.2.3.m
  • mozilla style 1a.2a3c. can be expressed as raw:{1.a.0.m}.{2.a.3.c}p{0.m.0.m} (mozilla is a complex format - see external links at the end of page).

Other formats

TBD

format string description
format(<transformation-pattern>) Specifies a version format consisting of a transformation pattern.

The transformation pattern can contain the following rules:

  • r - raw - matches one raw-element as documented for the raw format. If the matching 'r' element is the last element in the input string it may also be a pad-element.
  • 'character(s)' - matches a single character or sequence of characters - the matched result is not included in the resulting canonical vector (i.e. it is not a segment). A '\\' is needed to include a single '\'. The sequence of chars acts as one delimiter.
  • non-alphanum character - matches any non alpha-numerical character (including space) - the matched result is not included in the canonical vector (i.e. it is not a segment). A non alphanumerical character acts as a delimiter. Special characters must be escaped when wanted as delimiters.
  • a - auto - a sequence of digits creates a numeric segment, a sequence of alphabetical characters creates a string segment. Segments are delimited by any character not having the same character class as the first character in the sequence, or by the following delimiter. A numerical sequence ignores leading zeros. If a string segment starts with ' or " the string is treated as a quoted string, and the segment is delimited by the same character (the enclosing quotes are not part of the resulting string).
  • d - delimiter; matches any non alpha-numeric character.
  • s - a string group matching any character except any following explicit/optional delimiter
  • n - a numeric (integer) group. Leading zeros are ignored.
  • p - parses an explicit pad-element in the input string as defined by the raw format. To define an implicit pad as part of the pattern use the processing instruction =pad(). A pad element can only be last in the overall version string, or last in a sub array.
  • q - smart quoted string - if the first character of the string segment is a non alphanumeric character, the string is delimited by the same character. Brackets and parenthesises (i.e. (), {}, [], <>) are handled as pairs, thus 'q' matches "<andrea-doria>" and produces a single string segment with the text 'andrea-doria'.
  • ( ) - indicates a group
  • < > - indicates a group, where the resulting elements of the group is placed in an array, and the array is one resulting element in the enclosing result
  • ? - zero to one occurrence of the preceding rule
  • * - zero to many occurrences of the preceding rule
  • + - one to many occurrences of the preceding rule
  • {n} - exactly n occurrences of the preceding rule
  • {n,} - at least n occurrences of the preceding rule
  • {n,m} - at least n occurrences of the preceding rule, but not more than m times
  • {%n} - exactly n characters matching the preceding 's', 'n', 'q', or 'a' rule rule. For 'q' and quoted 'a', the quotes does not count.
  • {%n,} - at least n characters matching the preceding 's', 'n', 'q', or 'a' rule rule. For 'q' and quoted 'a', the quotes does not count.
  • {%n,m} - at least n characters matching the preceding 's', 'n', 'q', or 'a' rule , but not more than m characters. For 'q' and quoted 'a', the quotes does not count.
  • [ ] - short hand notation for an optional group. Is equivalent to ()?
  • =processing; - an additional processing rule is applied to the preceding rule. The processing part can be:
    • raw-element - use this raw-element (as defined by the raw format) as the default value if input is missing
    • ignore - if input is present do not turn it into a segment (i.e. ignore what was matched)
    • [<list of chars>] - when applied to a 'd' defines the set of delimiters. The characters ], ^, and \ must be escaped with \ to be used in the list of chars. and Example d=[+-/];
    • [^<list of chars>] - when applied to a 'd' defines the set of delimiters to be all non alpha numeric except the listed characters. The characters ], ^, and \ must be escaped with \ to be used in the list of chars. Example d=[^$]
    • pad(raw-element) - defines "padding to infinity with specified raw-element" when applied to an array, or a group enclosing the entire format. Example format((n.s)=pad(max);)
  • \ - escape removes the special meaning of a character and must be used if a special character is wanted as a delimiter. A '\\' is needed to include a '\'. Escaping a non special character is superflous but allowed.

Additional rules:

  • if the rule produces null segments, they are not placed in the result vector e.g. format(ndddn):10-/-12 => raw:10.12
  • Processing (i.e. default values) applied to a group has higher precedence than individual processing inside the group if the entire group was not successfully matched.
  • Parsing is greedy - format(n(.n)*(.s)*) will interpret 1.2.3.hello as raw:1.2.3.'hello' (as opposed to being reluctant which would produce raw:1.'2'.'3'.'hello')

Note about timestamps An earlier proposal had a 't' rule, but this rule has been deprecated because of the complexity. Instead, the creator of an IU should simply use 's' or 'n' and ensure comparability by using a fixed number of characters when choosing 's' format.

Named Version Formats

Named version formats makes it easier to enter version strings. There should be a number of predefined names as shown in the table below.

type name pattern comment
osgi n[.n=0;[.n=0;[.s]]]] Example: the following are equivalent:
  • format(n(n[.n=0;[.n=0;[.s]]]]):1.0.0.r1234
  • raw:1.0.0.'r1234'
  • osgi:1.0.0.r1234
  • 1.0.0.r1234
triplet n(.n=0;[.n=0;[.s=M;]]] A variation on OSGi, with the same syntax, but where the a lack of qualifier > any qualifier. The following are all equivalent:
  • format(n(.n=0;[.n=0;[.s=M;]]]):1.0.0
  • raw:1.0.0.M
  • triplet:1.0.0
tripletSnapshot n[.n=0;[.n=0;[-n=M;.s=m;]]] Format used when maven transforms versions like 1.2.3-SNAPSHOT into 1.2.3-<buildnumber>.<timestamp> ensuring that it is compatible with triplet format if missing <buildnumber>.<timestamp> at the end (format produces max, max-string if they are missing).

Example: the following are equivalent:

  • format(n[.n=0;[.n=0;[-n=M;.s=m;]]]):1.2.3-45.20081213:1233
  • raw:1.2.3.45.'20081213:1233'
  • tripletSnapshot:1.2.3-45.20081213:1233
rpm [n:]a(d?a)*[-n[ds=ignore;]] RPM format matches [EPOCH:]VERSION-STRING[-PACKAGE-VERSION], where epoch is optional and numeric, version-string is auto matched to arbitrary depth >= 1, followed by a package-version, which consists of a buildnumber separated by any separator from trailing platform specification, or the string 'src' to indicate that the package is a souce package. This format allows the platform and src part to be included in the version string, but if present it is not used in the comparisons. The platform type vs source is expected to be encoded elsewhere in such an IU.

An example of equivalent expressions:

  • format([n:]a(d?a)*[-n[ds=ignore;]]):33:1.2.3a-23/i386
  • raw:33.1.1.3.'a'.23
mozilla (<n=0;?s=m;?n=0;?s=m;?>(.<n=0;?s=m;?n=0;?s=m;?>)*)=pad(<n=0;?s=m;?n=0;?s=m;?>) Mozilla versions are somewhat complicated, it consists of 1 or more parts separated by period. Each part consists of 4 optional 'fragments' (numeric, string, numeric,string), where numeric fragments are 0 if missing, and string fragments are MAX-STRING if missing. The versions use padding when compared with longer versions so that 1 == 1.0 == 1.0.0 == 1.0.0.0 etc.
string s Perhaps superflous, but makes this version format appear in a selectable list of formats.
auto a(d?a)* Perhaps superflous, but makes this version format appear in a selectable list of formats, and it serves like a "catch all".

The version range delimiters are: '(', ')', '[', ']' and , ',' (comma).

Defining named formats

An IU can define new named formats. The named formats are defined by using a list of defined format names, and then one property per format.

org.equinox.p2.version.formats=<format-name>, <format-name>, ...
org.equinox.p2.version.format.<format-name>=formatstring

Once the format has been specified, it may be used in the IU. The format name should use java package name semantics to ensure unintentional clashes. When using the format names, the user may specify the last part of the name if it is unique. The predefined named formats should not be included in the formats property.

Thus, if an IU introduces the two named formats "org.mycorp.docver", and "org.mycorp.dbdataver" they are described like this:

org.equinox.p2.version.formats=org.mycorp.docver, org.mycorp.dbdataver
org.equinox.p2.version.format.org.mycorp.docver=n.n[s=max;]
org.equinox.p2.version.format.org.mycorp.dbdataver=n.'R'n[.s=ignore;]

When an IU is stored in a repository, the following processing is done:

  • The defined formats are extracted from the IU
  • If the fomat name does not already exist in the repository, it is added to the repositories list of contained formats.
  • If the format name already exists in the contained formats list and the format pattern is the same - nothing needs to be done
  • If the format name already exists in the contained formats list and the format pattern for the contained name is different - an exception is thrown

When using a non standard format name in an IU:

  • The format definition must also be stored in the IU.

Attempting to redefine pre-defined formats:

  • The pre-defined formats have higher precedence - should throw an exception

The user interface can:

  • collect all defined formats from all known repositories and present them when the user is defining a version or range
  • have a function to define a new format which is stored in the current profile (and thus becomes available for use)

This scheme allows format names to spread virally. The possible downside is potential clashes between repositories (same format name with different definitions in two different repositories) - but this is not a unique problem for version format. A particular IU of a particular version, or a particular artifact of a particular version, could very well be different in two repositories. As an aid/indicator, the UI can flag conflicting formats to the user.

A repository management tool could have a feature to enable modifying/replacing version fomats thus allowing repair.


More examples using 'format'

A version range with format equivalent to OSGi

format(n[.n=0;[.n=0;[.s]]]):[1.0.0.r12345, 2.0.0]

At least one string, and max 5 strings

format(s[.s[.s[.s[.s]]]]):vivaldi.opus.spring.bar5
format(s(.s){0,4}):vivaldi.opus.spring.bar5  => 'vivaldi', 'opus', 'spring', 'bar5'

At least one alpha or numerical with auto format and delimiter

format(a(d?a)*):vivaldi:opus23-spring.bar5  => 'vivaldi', 'opus', 23, 'spring', 'bar', 5

The texts 'opus' and 'bar' should not be included:

format(s['.opus'=ignore;n['.bar'=ignore;n]]):vivaldi.opus23.bar8   => 'vivaldi', 23, 8

Classic SCCS/RCS style:

format(n(.n)*):1.1.1.1.1.1.1.4.5.6.7.8

Max depth 8 of numerical segments (limited classic SCCS/RCS type versions):

format(n(.n){0,7}):1.1.1.1.1.1.1.4

Numeric to optional depth 8, where missing input is set to 0, followed by optional string where 'emtpy > any'

format(n(d?n=0;){0,7}[a=maxs;]):1.1.1.4:beta   => 1,1,1,4,0,0,0,0,'beta'
format(n(d?n=0;){0,7}[a=maxs;]):1.1.1.4   => 1,1,1,4,0,0,0,0,MAXSTRING

Uninterpreted single string range

format(s):[andrea doria,titanic]

Range examples

[[CommentBox| Needs to be edited}} Examples:

  • raw:[1.2.3.'r1234',2.0.0]
  • [1.2.3.r1234,2.0.0]
  • format(a+):[monkey.fred.ate.5.bananas,monkey.fred.ate.10.oranges]
  • [1.0.0,2.0.0] equal to osgi:[1.0.0,2.0.0]
  • format(s):[andrea doria,titanic]
  • rpm:[7:4.0.3-3.fc9,8:1] - an example KDE Admin version 7:4.0.3-3.fc9 to 8:1
  • triplet:[1.0.0.RC1,1.0.0]

Internationalization

The proposed types using alphanumerical segments are assumed to use vanilla string comparison. This does not work so well if versions are expressed in a language where lexical ordering is different. Language specific collation could be supported by combining version type name with the name of a ISO 639 Language code (see java.util.Locale) and where the default would be English. The language could be encoded with a separating '-' e.g. 'format-pt' for collation in Portuguese.

This opens up another can of worms (decomposition strength, comparison of locale and non locale specified types, etc.), and it is probably best to implement just basic string comparison. It is also questionable if internationalization is wanted at all, as "known tools" does not support this, and "correct collation" would thus yield a different result.

Support for internationalized collation is not recommended.


Factory API

The factory API could be something simple like this:

public class VersionFactory
{
    IVersion createVersion(String versionString);
    IVersion createVersion(String versionType, String versionString);
}
public class VersionRangeFactory
{
    IVersionRange createVersionRange(String versionRangeString);
    IVersionRange createVersionRange(String versionType, String versionString);
}

Hard to say how much indirection is required - methods could just be static to keep things simple.

If we want to support the pattern based type, the factory methods needs the pattern as well. To make this generic, it could be seen as a paramter to the version type.

public class VersionFactory
{
    IVersion createVersion(String versionString);
    IVersion createVersion(String versionType, String versionString);
    IVersion createVersion(String versionType, String versionTypeParameter, String versionString);
}
public class VersionRangeFactory
{
    IVersionRange createVersionRange(String versionRangeString);
    IVersionRange createVersionRange(String versionType, String versionString);
    IVersionRange createVersionRange(String versionType, String versionTypeParameter, String versionString);
}

When creating a pattern based version, the versionTypeParameter must be supplied. When creating a pattern based version range, the pattern is optional - the pattern of the individual candidates would then be used to create the canonical form of the upper and lower bounds.

IVersion and IVersionRange API

Basically follows the current Version and VersionRange classes.

Applicability

The generalization of version type applies to objects that by nature may have a different versioning scheme than OSGi. This includes:

  • Installable Unit
  • Provided Capability
  • Required Capability
  • Artifact key

These does not need to be generalized:

  • File format version numbers (content.xml, artifact.xml, etc)
  • Update Descriptor
  • Touchpoint version numbers and touchpoint action versions
  • Publisher advice versions

Implementation Steps

Enablement of an alternate implementation of Version and VersionType is wanted in 3.5 even if the OSGi resolver is still used. This enablement is available as a patch. On a parallell track - the Omni-version classes are implemented and tested with either a SAT4J based solution or an interims replacement of the OSGi resolver. It is then possible to verify the functionality and performance of the Omni-version implementation.

The Omni-version implementation is not expected to go into 3.5 unless there is a SAT4j solution replacing the OSGi resolver, the functionality and performance is satisfactory, and enough testing has taken place.

The feature to allow introduction of new named formats can wait.

FAQ

Will users just using Eclipse and OSGi bundles be affected?
No, users that only deal within the OSGi domain can continue to use version strings like before, there is no need to specify version formats. The Enablement that is proposed should also be safe as it is only a level of indirection to the current implementation of Version and VersionRange.

How does a user of something know which version type to use? This seems very complicated...
To use some non-osgi component with p2, that component must have been made available in a p2 repository. When it was made available, the publisher must have made it available with a specified version format. The publisher must understand the component's version semantics. A consumer of the component can find the version format in the repository (the user must after all know that a capability is available under a certain name, and certain version range).

Will open (osgi) ranges produce lots of false positives?
Very unlikely. One decision to minimize the risk was to specify that integer segments are considered to be later than string segments. (We also felt that version segments specified with integers are more "precise"). Note that to be included in the range, the required capability would still need to be in a matching name space, and have a matching name. To introduce a false positive, the publisher of the false positive would need to a) publish something already known to others (namespace and name) b) misinterpret how its versioning scheme works, and publishing it with a format of n.n.n.n (or n.n.n.s.<something>), c) having first learned how to actually specify such a format and how to publish it to a p2 repository and d) then persuaded users to use the repository.

What happens when a capability is available with several versioning schemes?
A typical case would be some java package that is versioned at the source using triplet notation, and the same package is also made available using osgi notation (which is a mistake).

As an example, the following capabilities are found:

  • org.demo.ships triplet:2.0.0
  • org.demo.ships triplet:2.0.0.RC1
  • org.demo.ships osgi:2.0.0
  • org.demo.ships osgi:2.0.0.RC1

(Reminder: in triplet notation 2.0.0.RC1 is older than 2.0.0).

The raw versions will then look like this:

  • 2.0.0.maxs
  • 2.0.0.'RC1'
  • 2.0.0
  • 2.0.0.'RC1'

And the newest is 2.0.0.maxs (which is correct for both OSGi, and triplet). When specifying a range, the outcome may depend on if the range is specified with osgi or triplet notation.

  • osgi:(1.0.0,2.0.0) == raw:(1.0.0, 2.0.0) => matches the osgi:2.0.0 version only
  • triplet:(1.0.0,2.0.0) == raw:(1.0.0.maxs,2.0.0.maxs) => matches all the versions, and picks 2.0.0.maxs as it is the latest.

i.e. result is correct (assuming the bits are identical as different artifacts would be picked)

Now look at the lower boundary, and assume that the following versions are the (only) available:

  • org.demo.ships triplet: 1.0.0 == raw: 1.0.0.maxs
  • org.demo.ships triplet: 1.0.0.RC1 == raw:1.0.0.'RC1'
  • org.demo.ships osgi: 1.0.0 == raw:1.0.0
  • org.demo.ships osgi:1.0.0.RC1 == raw:1.0.0.'RC1'

When specifying ranges:

  • osgi:(1.0.0,2.0.0) == raw:(1.0.0, 2.0.0) => matches all the version, and picks 1.0.0.maxs as this is the newest
  • triplet:(1.0.0,2.0.0) == raw:(1.0.0.maxs,2.0.0.maxs) results in 1.0.0.maxs as it is the only available version that matches.

i.e. the result is correct and here the exact same version is picked.

The "worst osgi/triplet crime" that can be committed is publishing an unqualified triplet version as an osgi version (if the same version is not also available as a triplet) as this would make that version older than what it is even when queried using a triplet range.

What if the publisher of a component changes versioning scheme - what happens to ranges?
The order among the versions will be correct as long as the versions are published using the correct notation. The only implication is that users must understand that a query for triplet:x.x.x means raw:x.x.x.maxs - e.g. osgi:(1.0.0,2.0.0) != triplet:(1.0.0,2.0.0) (osgi upper range of 2.0.0 would not match triplet published 2.0.0, and triplet lower range of 1.0.0 would not match osgi published 1.0.0).

Why not use regexp instead of the special pattern format?
This was first considered, and would certainly work if the pattern notation was augmented with processing instructions, or if the regexp is specified as a substitution that produces the raw format. Such specifications would typically be much longer and more difficult for humans to read than the proposed format, except possibly for regexp experts :). Another immediate problem is that regexp breaks the current API requirement. It is not included in execution environment CDC-1.1/Foundation-1.1 required by p2.

Pattern parsing looks like it could have performance implications - what are the expectations here?
The intention is to use a mechanism similar to reqular expressions - when a format is first seen it is compiled to an internal structure. The compiled structure is cached and reused for all subsequent occurrences of the same format. A test will be performed to compare current parsing of an OSGi version string with the pattern based parsing. Once parsed, all comparisons are made using the raw vector, which should be comparable in speed to the current implementation.

Why not just let the publisher deal with transforming the version into canonical form?
There are several reasons:

  • the original version strings needs to be kept as users would probably not understand the canonical representation in many cases.
  • if the transformation pattern is not available a user would not be able to create a request without hand coding the canonical form
  • making the transformation logic used by one publisher available to others would mean that all publishers must have extensions that allow plugging in such logic, and the plugins must be made available

Would it be possible to use the current OSGi version as the canonical form?
The long answer is: To be general, the encoding would need to be made in the qualifier string part of the OSGi version. An upper length for segments must be imposed, numerical sections must be left padded with "0" to that length, and string segments must be right padded with space (else string segment parts may overlap integer segments parts). The selected segment length would need to be big enough to allow the longest anticipated string segment. A serializable representation of MAX_STRING must be invented. A different implementation would still be needed to be able to keep the original version strings.
The short answer is: no.

Why not use an escape in string segments to be able to have strings with a mix of quotes? There are several reasons:

  • this would mean that the version string would need to be preprocessed as it would not have \ embedded from the start
  • all version strings that use \ as a delimiter would need to be pre-processed to escape the the \
  • to date, authors of this proposal have not seen a version format that requires a mix of quotes
  • parsing performance is affected

External Links

Back to the top