On 2 November 2010 09:02, Sahoo <[email protected]> wrote: > [Apology if this is a duplicate. I sent the earlier email from my Sun.COM > email which does not subscribe to this ML] > > I am repackaging a couple of jars into one bundle and in the process, I > have to exlclude a few classes from the second jar, as I will be creating a > second bundle containing only those excluded classes. The motivation here is > that the second bundle will act as a fragment to the first bundle and it > will be only available in environment where its dependencies are satisfied. > So, consider the following example: > > a1.jar and a2.jar are being repackages into b1.jar and b2.jar. > b1.jar contains all classes from a1.jar and a2.jar except the classes > having following pattern: p.q.r.Foo* > b2.jar contains classes having following pattern: p.q.r.Foo*Impl. > > So, I am configuring my pom.xml like this: > > <project> > <parent> > <groupId>xxx</groupId> > <artifactId>external</artifactId> > <version>1.0-SNAPSHOT</version> > </parent> > <modelVersion>4.0.0</modelVersion> > <artifactId>a1-a2--repackaged</artifactId> > <packaging>jar</packaging> > <build> > <plugins> > <plugin> > <groupId>org.apache.felix</groupId> > <artifactId>maven-bundle-plugin</artifactId> > <version>2.0.1</version> > <configuration> > <instructions> > <Export-Package> !p.q.r.Foo*, p.q.* </Export-Package> > <Private-Package>!*</Private-Package> > <Import-Package>*</Import-Package> > </instructions> > </configuration> > <executions> > <execution> > <id>osgi-bundle</id> > <phase>package</phase> > <goals> > <goal>bundle</goal> > </goals> > </execution> > </executions> > </plugin> > </plugins> > </build> > <dependencies> > <dependency> > <groupId>p.q</groupId> > <artifactId>a1</artifactId> > <version>1.0</version> > </dependency> > <dependency> > <groupId>p.q</groupId> > <artifactId>a2</artifactId> > <optional>1.0</optional> > </dependency> > </dependencies> > </project> > > Yet, I see p.q.r.Foo, p.q.r.FooImpl and similarly named classes being part > of the bundle. What am I doing wrong. I do see the following warning: > [WARNING] Warning building bundle xxx:a1-a2-repackaged:jar:1.0-SNAPSHOT : > Instructions in Export-Package that are never used: *p\.q\.r\.Foo.** > > So, it seems it is expecting a package pattern there and I am trying to > give a class name pattern. How to exclude a few classes then? >
try using m-b-p's Embed-Dependency as that supports regexp inclusion of contents (translates to Include-Resource under the covers) then use the -exportcontents directive to choose which packages you want to export (as this won't pull any classes from the classpath) Thanks, > Sahoo > -- Cheers, Stuart

