osgipom.xmlmaven-bundle-plugin

how to use maven bundle plugin to exclude package out of bundle


i have a bundle that uses maven-jaxb2-plugin to generate all classes to target/generated/src/main/java. Then i use maven bundle plugin to create a bundle. It simply works.

Now, i want to exclude (remove) a generated package com.xxx.yyyy.common out of this bundle. So i use:

<Export-Package>
     !com.xxx.yyyy.common,com.xxx.*
</Export-Package>

But after having a bundle, that package is still there inside the bundle.


Solution

  • I have made it works. Basically, we need to use a combination between <Export-Package> and <Private-Package>. Tell maven bundle plugin to not export this package and this package is not a private package --> that means we dont need to keep this package in the bundle

    <Export-Package>!com.xxx.yyyy.common</Export-Package>
    <Private-Package>!com.xxx.yyyy.common</Private-Package>