Overwrite manifest header written by Bnd plugin

I ran into an edge case where a Bnd plugin (felix-dev/tools/org.apache.felix.scr.bnd at 81edc6e48db29feae5d0deb0af23719f50ddcb2b · apache/felix-dev · GitHub) writes an incorrect header (Service-Component) which I need to fix afterwards (details in Cannot register component. The component name 'com.adobe.acs.commons.<Component>' has already been registered by Bundle · Issue #3241 · Adobe-Consulting-Services/acs-aem-commons · GitHub). Is there any way on how to achieve this with Bnd itself? Unfortunately fixing the errorneous Bnd plugin itself is hard to achieve (no longer maintained, I don’t want to come up with a fork)

I am thinking about a plugin which is executed after the Bnd-Scr-Plugin or some built-in bnd post processors which can fix a Manifest header.
Any pointers would be much appreciated.
Thanks in advance

Why not just wrap the bundle? As far as I can see the wrapped bundle will then have a correct manifest.

-includeresource @{repo;...}
-exportcontents foo.bar

Are you proposing to execute bnd-maven-plugin:bnd-process twice? First with Felix SCR Bnd Plugin and then without (wrapping the results of the first run and overwriting the Service-Component header in the Manifest)? I was hoping for a workaround with less build time overhead…

Due to the order of precedence one cannot tweak the MANIFEST.MF with the maven-jar-plugin either: plexus-archiver/src/main/java/org/codehaus/plexus/archiver/jar/JarArchiver.java at 8fc09830db295fe07ffbf841e1033a07b99e9f24 · codehaus-plexus/plexus-archiver · GitHub

I was proposing to build the bundle in the old way but give it another name and then build it again using the -includeresource etc. Worst case you have to maintain the manifest but since you do not want to change this bundle, I guess the maintenance on it is low.

That said, in my 50 years of experience in builds, these kind of hacks to not wanna do it right tend to be at the root of all incredible complexity a few years later. Take the technical debt now instead of postponing it, it only gets worse. Always pick the right solution, not the most convenient. In this case, I would change the bundle using the old bnd plugin however painful it is. Anyway, 2cts of an old man.

I agree that cleaning up is the best solution (and get rid of the broken Bnd plugin). FTR: For now I just fix the Manifest with maven-shade-plugin transformers: Apache Maven Shade Plugin – Resource Transformers