The convention the bundle uses for determining which packages to export
by default is reasonable, unfortunately none of our modules appear to
comply with it.  We could use this approach for future modules. ;)

-----Original Message-----
From: Stuart McCulloch [mailto:[email protected]] 
Sent: 29 March 2010 16:14
To: [email protected]
Subject: Re: "gotcha" with Export-Package.

On 29 March 2010 07:57, peter lawrey <[email protected]> wrote:

> When using org.apache.felix/maven-bundle-plugin, it appears that when
> you specify a wildcard for a package, it will take all the matching
> packages in the classpath, rather than just that module.
>
> Module1
>
> <Export-Package>com.mycom.api.d.*</Export-Package>
>
> Module2 depends on Module1
>
> <Export-Package>com.mycom.api.*</Export-Package>
>
> This results in Module2 including the classes from Module1 rather than
> only matching packages from Module2.
>

correct, this is the Bnd Tool working as designed

it takes the given project compilation classpath (in this case from
Maven)
and
applies the instructions to decide what classes to include inside the
bundle
-
Bnd considers the whole classpath because 1) you might want to slice it
into
different bundles, and 2) you often want to merge so-called 'split'
packages

if you want to reduce the classpath passed from Maven to Bnd you can use
the
<excludeDependencies> configuration setting (note this is a plugin level
setting,
not a Bnd instruction)

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
 
<excludeDependencies>*;artifactId=!module1</excludeDependencies>
        </configuration>
      </plugin>

( <excludeDependencies> uses the same format as Embed-Dependency )

in an ideal world you should be reducing the amount of packages that you
export,
then you don't need to use a wildcard - also you might also want to try
using the
bundleplugin defaults, which generate Export-Package & Private-Package
based
on the source code under the project directory

for a stock Maven project you typically just need to flip the packaging
from
'jar' to
'bundle' and not worry about OSGi/Bnd specific instructions unless the
generated
defaults don't match your needs

HTH

-- 
Cheers, Stuart

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to