Yes, this is a difficult issue to fix in a re-usable way.
A few points about this:
- I guess all packages (excluding impl packages) should be exported. There is not really a reason I didn't export io.vertx.groovy.ext, and probably should be doing that.
- All optional dependencies should get optional, or even dynamic import packages, assuming that Vertx already handles the optional loading of these classes. groovy.lang is an example of this. From the Vertx side, is it possible to dynamically add these optional features? E.g. is the optional classpath loading re-checked every invocation? In that case dynamic imports would be the better choice.
- For this to fully work, all Vertx modules should become valid OSGi bundles following these same principles, ideally wrapping their transitive dependencies.
Specifically for the activator I created that registers Vertx and Router as services, there is one more problem; *if* you're using the RX API, these services should be registered using that API. I guess there are two options:
1) Use conditional class loading to check if RX is available or not, register services based on that
2) Write two versions of the Activator, available in two different bundles. E.g. a Vertx-Web-OSGi bundle (that only contains the activator), and a Vertx-Web-Rx-OSGi bundle.
Looking at the Vertx code, should all classes *not* in impl be available to users?
Bnd has a new Maven plugin available that is much better than the bundle plugin from the Felix project (which is currently used in vertx-core). Would it make sense starting an experiment to add this plugin to some of the modules (e.g. Vertx Web, Rx) to see if we can get this to work without manual wrapping like I did?
Cheers,
Paul