Includeresource: Exclude OSGI-INF resources

I am trying to wrap multiple osgi bundles into a single uber-jar bundle.
From some source bundles I want to strip the declarative services being defined in folder OSGI-INF.

I tried the following instructions in the bnd file:

-includeresource: @mybundle-1.0.0.jar!/!(OSGI-INF/*), ...

But still the OSGI-INF from mybundle ends up in the resulting bundle. I guess this is because the services are referenced in the META-INF/MANIFEST.MF. For all other regular folders the exclusions work properly.

How can I build an uber-jar from multiple bundles but leaving out some declarative services? Is there some special instruction or bnd plugin for it or do I rather have to use something like maven-shade-plugin?

doesn’t work? Not sure what you meant by using the parentheses.

Same result, unfortunately. The OSGI-INF is still part of the destination bundle.

Are you sure Bnd is not regenerating DS, Metatype, etc from the jar contents? You may need to disable annotation processing by Bnd. e.g.

-dsannotations:
-metatypeannotations:

note that, with @bjhargrave 's suggestion, you can use negative package syntax to prevent only certain packages from being analyzed by certain plugins:

-dsannotations: !this.package, *
-metatype: !this.package, *

Thanks a lot for that pointer. Indeed the DS and metatype metadata were regenerated from the given bundle. For some reason I assumed that DS annotations had a SOURCE retention policy (RetentionPolicy (Java Platform SE 8 ))
With

-dsannotations:
-metatype:

I could disable generating DS component metadata but the metatype is still being generated for some reason…

Oops. Its actually -metatypeannotations:.

Thanks again. Would you mind adding an entry for that instruction to Instruction Index | bnd?

Done: docs: Fix documentation for Metatype annotation processing instructions by bjhargrave · Pull Request #5380 · bndtools/bnd · GitHub

1 Like