Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to exclude certain file while generating a bundle from jar? #311

Open
azaylamba opened this issue Dec 9, 2022 · 3 comments
Open

How to exclude certain file while generating a bundle from jar? #311

azaylamba opened this issue Dec 9, 2022 · 3 comments

Comments

@azaylamba
Copy link

Hi,

Can someone please help me with how to exclude certain file from the jar while generating OSGi bundle using p2-maven-plugin? I want to exclude INDEX.LIST file as it is causing issues in my project while loading the jar because of the jar name present in INDEX.LIST is different from the OSGi bundle.
I tried using invalidfilenames instructions but it had no impact. I might be using it incorrectly. The instruction format I used is "<_invalidfilenames>INDEX.LIST</_invalidfilenames>"

@sparsick
Copy link
Collaborator

sparsick commented Dec 9, 2022

Hi @azaylamba

you have to do it with the underlying bnd tool. It is responsible for repacking of the jar.

Check the donotcopy option of it

https://bnd.bndtools.org/instructions/donotcopy.html

@azaylamba
Copy link
Author

Hi @sparsick, thanks for the quick response. I tried donotcopy option with p2-maven-plugin but it didn't work. Can you please confirm whether the plugin supports this or I would need to package my jar using bnd tool only and not using this plugin?

@sparsick
Copy link
Collaborator

Hi @azaylamba,

you can add BND instruction to your artifact configuration:

<artifact>
    <id>commons-io:commons-io:2.1</id>
    <transitive>true</transitive>
    <source>false</source>
    <override>false</override>
    <singleton>false</singleton>
    <instructions> <!-- here you can out bnd instruction-->
        <Import-Package>*;resolution:=optional</Import-Package>
        <Export-Package>*</Export-Package>
        <_fixupmessages>"Classes found in the wrong directory";is:=warning</_fixupmessages>
        <_removeheaders>Bnd-LastModified</_removeheaders>
        <_reproducible>true</_reproducible>
    </instructions>
    <excludes/>
</artifact>

Here it is described how to put bnd instruction to the plugin. P2 Plugin uses the mechanism of the maven bundle plugin.

I hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants