Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Split packages (repackaging OpenIMAJ as OSGi bundles) #130
This is an issue that doesn't affect your usual OpenIMAJ use case (with just a single class-loader), but makes repackaging OpenIMAJ dependencies as OSGi bundles needlessly complicated (and at the cost of losing out on modularity).
Split packages (i.e. multiple jars offering classes under the same package namespace) are a problem in the OSGi world, leading to the situation that only one (partial) package is visible to a given class-loader (from some bundle). The situation could be dealt with "Require-Bundle", but that's rather ugly (see OSGi 6.0.0 core specification, 3.13 Requiring Bundles, p.79).
Problem: OpenIMAJ split packages
There might be more such cases, but so far I've found two of them:
A simple and straight-forward repackaging (e.g. with maven-bundle-plugin) of
Fix (in the meantime)
To solve this issue, I didn't go the require-bundle route, instead I've built an extended core-math bundle including all classes from core-math, core-feature, and mtj (maven-dependency-plugin:unpack), thereby merging them (and the split-packages) into a single bundle. This works fine, but it's a bit of a hack (and depending on licenses maybe not even legal), and obviously takes away modularity.
The proper solution would be to not have split packages in the first place. And I think this could be easily achieved with a tiny bit of refactoring. The two cases above show a clear pattern of a second bundle "adding to/extending" another bundle. A simple and clear fix would, while still using the same (root) namespace, at least use its very own, distinct sub-package. For example:
that need to be moved out of their packages into their own, exclusive ones. Again either something like
Now, I understand such a fix/refactoring will break someone's code, so this is probably not something for a minor update. But maybe consider this for the next major update, and until then, maybe make sure to not introduce even more split packages in the meantime.
P.S. Bonus points for adding OSGi bundle manifests to all OpenIMAJ jars in the future. ;)
EDIT: There are some more split packages:
...thus so far, I ended up creating three "extended" bundles to deal with these split packages, thereby losing quite some modularity:
The case with