To put a generic library – e.g. client libraries for our services, or common stuff like the link rewriter – into the TextGridLab, the following steps are neccessary:
maven-bundle-plugin) and deploy it to a Maven repository
textgridlab-dependenciesproject for that.
There are some caveats in each of the steps.
In principle, your library can be OSGified by adding specific metadata to its Manifest file. There is a Maven plugin, the maven-bundle-plugin, created in the Apache Felix project and using the
bnd bundling tool, that is able to auto-generate the metadata for you. There are two alternative ways to use this plugin:
bundlefor your project
jar, but add an execution to your build that calls the bundle plugin's
manifestgoal to manipulate the bundle manifest.
You should avoid version 2.3.5 of the bundle plugin since it collides with generating source jars. Both earlier and later versions are fine, we have not yet encountered any specific trouble with version 2.4.0.
Your OSGified bundle will have two versions, and this is bound for trouble since the versioning systems are fundamentally different:
The Maven version will be used when (plain) Maven is used to resolve the library, e.g., from a Maven repository. The OSGi version is used by, e.g., Eclipse and p2. Note that Felix, as opposed to Tycho, includes a literal SNAPSHOT in the OSGi version number instead of expanding it, making different SNAPSHOTs of the same version indistinguishable for p2. Thus, you should update your snapshots' explicit version numbers if you want to force your plugin to land in the TextGridLab.
We maintain a project as part of the TextGridLab build that is used for the transformation from the Maven world to the Eclipse/p2 world – textgridlab-dependencies. This project is integrated in the TextGridLab integration build, and we're using a Jenkins build to deploy its result to a p2 update site from which the other TextGridLab components fetch their dependencies.
Like the other TextGridLab components, textgridlab-dependencies uses the Git Flow model, so please push your commits into the
dependenciessection of textgridlab-dependencies' root POM. Please use a property for the version number.
modulesentry to the root pom.xml. You can also add your dependency to a suitable existing feature.
plugin entry for your library to your feature.xml:
<plugin id="info.textgrid.utils.linkrewriter.core" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
The ID ② is the
Bundle-Symbolic-Name of the OSGi bundle, it is typically generated by the maven-bundle-plugin using a sensible heuristic. You should use
download-size ③ and
install-size ④ as these will by calculated on build. We also recommend to insert
0.0.0 as version ⑤ – this will be replaced by the actual version used on build (and specified by you in the root
Import-Packagesstatement or to the
Required-Bundlesstatement (both can be found in the bundle manifest editor). You should specify version dependencies. If you intend to use new features after an upgrade of your library, you must use version dependencies to make this explicit.