"includeresource" in a bndrun for the testing and run plugin

Hi all,

Not sure if this is possible at all, but I’m using “-includeresource” to add a (log config) file to an exported target. How can I use those same resources when using the run and/or testing plugin?

Also, related, if I use “-includeresource.log” with the idea of a merged instruction, those instructions are never processed. Stripping the “.log” part makes it work as expected. Is this not supported?

Thanks in advance!

This is imminently feasible … so the fact that you’re having problems means your setup is incorrect. So maybe you can make an example workspace/project where this is not working as you expected?

Hi Peter,

I’ve created an example, see GitHub - abroekhuis/maven-bnd-example

It is a maven project which has 2 modules. The first module (shared) shares a bnd file in which I defined some groups of runfeatures for bundles, which can have properties and resources.

In the second module (use) the shared bnd file is included and the base and shell feature are used (base is used by default). Together with the bundle artifact this gives a simple runtime with shell.

The first issue I see:
In the shared bnd file I try to include a logback.xml file using the merging syntax. This file is never picked up. In the run.bndrun of the use module there are 2 additional includeresource calls with some comments. Only the includeresource without merge instruction works as expected.

The second issue I have:
In the shared bnd file I include a runproperty to specify the logback.xml file (logback.configurationFile=${fileuri\;${.}/logback.xml}). This results in a fixed path, and while this works fine when using the bnd-run:run target, this does not work when exporting the same bndrun file.
Again, I have used the run.bndrun in the use module to test this, see comments in there. If I add the resource, and change the property to use the direct file, it works for the exported target. But then running directly does not work anymore.

Is there a way to have both options? Or is the solution here to have 2 different bndrun files? One for export, one for running?

Thanks again!

I hope someone else can answer this, I am not really into maven … and that is relevant here since the rules where to find files and how to process them are relevant.

Try making the include an absolute path by adding ${.} like:

-include: ${.}/target/dependency/shared/shared.bnd

let’s see where that gets you.

First, why are you using 5.2.0-SNAPSHOT version for the bnd maven plugins? 6.0.0 is the latest. I could not build unless I fixed the versions.

The above is also important.

Your if tests are also wrong. They should look like:

-runrequires.base: \
    ${if;${retainall;${runfeaturesMerged};base}; \

Finally, the exporter uses the ProjectLauncherImpl class and this class does not handle merged -includeresource. bnd/ProjectLauncherImpl.java at 9ff2e69ce3f2661697f2e7adf313659f16ec32e7 · bndtools/bnd · GitHub

Hi BJ,

Thanks for the reply! I’ll update my code to you example, it worked the way it was, but this looks better!

Since merging works for bundles themselves, does it make sense to open a feature request for it to work for the launcher as well?

Sure, go ahead and open an issue.