Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Ceylon to OSGi version transformation

Tako Schotanus edited this page Oct 19, 2016 · 5 revisions

This page is a summary of the discussion found in issue ceylon/ceylon#6006

The algorithm for changing a Ceylon version (not just for the distribution but any version) to an OSGi compatible version is the following:

  1. split the Ceylon version on . and - and on any switch from letter to digit or vice-versa
  2. make sure the first 3 parts are numbers, if not, insert enough "0"s before the first non-number part or on the end to get to 3
  3. for each part after the first 3 that is a number left pad with 0s to 3 digits (3 should be enough, right?) and prefix with the letter n
  4. for each part consisting of letters look the text up in the qualifier table below and if found replace the text with the index in the table, if not found prefix the part with 7-
  5. insert a part with the text osgi at the 4th position
  6. join all the parts together separating the first 4 by a dot . and all the rest by a dash -
  7. if the last part added was not a qualifier we add an extra -5. This to make sure that a version that has no qualifier will be in 5th place, same as ga and final.

Qualifier table

  • 0 = alpha or a
  • 1 = beta or b
  • 2 = milestone or m
  • 3 = rc or cr
  • 4 = snapshot
  • 5 = (the empty string) or ga or final
  • 6 = sp
  • 7 = (any other string)

This should be good enough to create OSGi versions that in almost all cases follow the same ordering as the Ceylon versions.

So as an example "1.1-RC2" following those rules becomes (step by step):

  1. [ "1", "1", "RC", "2" ]
  2. [ "1", "1", "0", "RC", "2" ]
  3. [ "1", "1", "0", "RC", "n002" ]
  4. [ "1", "1", "0", "3", "n002" ]
  5. [ "1", "1", "0", "osgi", "3", "n002" ]
  6. "1.1.0.osgi-3-n002"
  7. "1.1.0.osgi-3-n002-5"

Following the same rules:

Ceylon OSGi
1.15.xyz 1.15.0.osgi-7-xyz
1.1-rc 1.1.0.osgi-3
23.108.5.337.4 23.108.5.osgi-n337-n004-5
abc 0.0.0.osgi-8-abc-5
Clone this wiki locally