Notice the duplicates:=APPEND in the last line.
This should mean that when unrolling the second file all duplicated files in /services folder, their content should be appended to the existing file with the same name (instead of overwriting it)
Possible strategies could be:
OVERWRITE (default)
APPEND (this would be the new one)
NOTHING (or maybe IGNORE / SKIP?)
Full Example
Consider the following bnd.bnd to wrap 4 bundles regarding Apache FOP.
The problem is that FOP supports an extension mechanism via ServiceLoader in META-INF/services
To solve classloading issues a possible solution is to wrap all FOP-related jar files into a single bundle.
BUT: Their META-INF/services need to be in the bundle root and basically need to be merged together, so that the bundle-classloader of the new resulting JAR can see them.
the duplicates:=APPEND at the end of @${repo;org.apache.xmlgraphics:xmlgraphics-commons;latest}!/META-INF/services/*;:duplicates:=APPEND
should append the content of org.apache.xmlgraphics:xmlgraphics-commons.jar/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreLoader the the content of fop-core.jar/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreLoader which was added first.
Scenario
The instruction -includeresource has various unroll options to add content from multiple jars to the resulting bundle jar.
e.g. the following line
@${repo;org.apache.xmlgraphics:fop-core;latest}!/META-INF/services/*,\
extracts the
META-INF/services
folder including all files into the resulting jar.Problem to solve:
If two or more bundles contain the same filenames then the files in the resulting jar are overwritten (last one wins).
Proposed solution:
-includeresource
should allow to specify aduplicate-strategy
so that you can define what should happen with files with the same name:Notice the
duplicates:=APPEND
in the last line. This should mean that when unrolling the second file all duplicated files in /services folder, their content should be appended to the existing file with the same name (instead of overwriting it)Possible strategies could be:
Full Example
Consider the following
bnd.bnd
to wrap 4 bundles regarding Apache FOP. The problem is that FOP supports an extension mechanism via ServiceLoader inMETA-INF/services
To solve classloading issues a possible solution is to wrap all FOP-related jar files into a single bundle. BUT: Their META-INF/services need to be in the bundle root and basically need to be merged together, so that the bundle-classloader of the new resulting JAR can see them.
Notice the
duplicates:=APPEND
in the last line.META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreLoader
with the contentMETA-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreLoader
with the contentGoal:
duplicates:=APPEND
at the end of@${repo;org.apache.xmlgraphics:xmlgraphics-commons;latest}!/META-INF/services/*;:duplicates:=APPEND
org.apache.xmlgraphics:xmlgraphics-commons.jar/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreLoader
the the content offop-core.jar/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreLoader
which was added first.Result should look like
wrap.jar/META-INF/services/org.apache.xmlgraphics.image.loader.spi.ImagePreLoader: