Is there a bnd or bndtools service to launch/run/debug a osgi framework programmatically…using a .bndrun file to specify the bundles/config/etc?
There is the bndrun editor in Eclipse, of course, which can also export to a executable jar, but I would prefer to launch my osgi framework process from another java app while in Eclipse workspace.
Just to make sure I understand your correctly: You want to launch a e.g. plain Java App from Eclipse and this App then should launch a bndrun?
Yes that would do.
Since the post must be at least twenty characters…
If you have a Workspace with a cnf Project you can do the following:
try (Workspace ws = new Workspace(wsRoot); Bndrun bndrun = Bndrun.createBndrun(ws, bndrunFile)) {
bndrun.run();
}
Hi @juergen-albert
First, thanks for the Bndrun pointers…this is getting closer to what I’m looking for.
What I would like to have available would be something like what the output of the bndrun editor Export->Executable Jar->Directory exporter produces: a launch.properties with jars/* bundles and aQute on classpath with start/start.bat.
Through debugging it seems that what the bndrun editor Run/Debug OSGi is actually very close to what I’m looking for…i.e. it generates a launch.properties file and passes a java command line that uses -Dlaunch.properties= /generated/launch722342354252435.properites file (in project/generated directory) launches the app (either in Run or Debug) and then after launched process exits it deletes the generated/launch722342354252435.properties file.
I’m looking for something in between the Run/Debug and Export behavior…i.e. it not only generates the launch.properties (as both do). It would be ideal if it generated the launch.properties (as the Run/Debug and Export do…hopefully with the same code…I haven’t debugged through/found that code yet so pointers would be appreciated) and like the Export it actually copied the bundles and the aQute launcher code to new directories…perhaps in some project dir (like ‘build’) so that the contents could be copied and launched from outside Eclipse.
Also if the command line that the DebugPlugin.exec uses could be saved to this ‘build’ for later reference (i.e. the system properties…like -Dlaunch.properties=path and launch.directory) along with the fq main class (EmbeddedLauncher) that would be useful.
I was thinking that this could be automatically done by Run/Debug …perhaps if a bndtools preference was set (that could define the ‘build’ directory), or there was some option set in the bndrun file. I’m not sure which would be more consistent with how bndtools works now wrt building.
Perhaps it already exists now…or I’m willing to help implement something like this if desired. I just need to be pointed to the relevant pieces in the Run/Debug and Export code.
Yes it answered my question.
I think bndtools would be well-served to give more progressive disclosure in UI of bnd commands (including but not limited to export), but that’s for y’all to work out.