0

I want to exclude some packages from copying when creating an OSGi bundle using maven bundle plugin.

I used !package name in the export section. But since I'm using @openejb-core-${openejb.version}.jar!/**, in the include-resource section that package gets copied to the bundle.

How can I avoid copying a particular package or set of packages using maven bundle plugin?

I can use names in resource section, but I'd rather not list them one by one.

Siguza
  • 21,155
  • 6
  • 52
  • 89

1 Answers1

0

Typically your build section of an osgi bundle looks like this:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-scr-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-Category>Your Category/Company</Bundle-Category>
                    <Import-Package>
                       <!-- put here some optional depependencies which are already provided by other bundles -->
                        org.apache.lucene.*;resolution:=optional,
                        *
                    </Import-Package>
                    <Export-Package>
                        com.yourproject.code.to.be.exported.*;version=${project.version}
                        <!-- exclude packages by negating with the prefix !, see http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html for more info -->
                        !com.do.not.include.package.*;version=x.y.z
                    </Export-Package>
                    <Embed-Dependency><!--put here some thirdparty artifacts you want to embed in your bundle--></Embed-Dependency>
                    <Include-Resource>{maven-resources}</Include-Resource>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

See also http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html

d33t
  • 1,143
  • 6
  • 15
  • yeah. I know this. I want to Include some resources in my bundle. So I put @openejb-core-${openejb.version}.jar!/** then it copy resource + all the class files to the bundle even I don't export some of those packages. – Thusitha Thilina Dayaratne Jun 12 '15 at 13:54