2009/5/4 Christopher Armstrong <[email protected]>

> Hi
>
> I'm trying to use the maven-bundle-plugin (2.0.0) to hide a package in
> my bundle. I'm specifying the package name in the Private-Package
> header, but the maven-bundle-plugin still exports it and lists it under
> the Private-Package header. Effectively I'm getting this:
>
> Manifest-Version: 1.0
> Export-Package: org.test;uses:="org.osgi.framework"
> Private-Package: org.test
> Built-By: chris
> Tool: Bnd-0.0.311
> Bundle-Name: Unnamed - maven.testproject:maven-test:bundle:0.0.1-SNAPS
>  HOT
> Created-By: Apache Maven Bundle Plugin
> Bundle-Version: 0.0.1.SNAPSHOT
> Build-Jdk: 1.6.0_0
> Bnd-LastModified: 1241413506557
> Bundle-ManifestVersion: 2
> Import-Package: org.osgi.framework;version="1.4",org.test
> Bundle-SymbolicName: maven.testproject.maven-test
>
> My pom.xml file contains the following for the maven-bundle-plugin:
>
>    <plugins>
>      <plugin>
>        <groupId>org.apache.felix</groupId>
>        <artifactId>maven-bundle-plugin</artifactId>
>        <version>2.0.0</version>
>        <extensions>true</extensions>
>        <configuration>
>          <manifestLocation>META-INF/</manifestLocation>
>          <instructions>
>            <Private-Package>org.test</Private-Package>
>          </instructions>
>        </configuration>
>      </plugin>
>    </plugins>I'm using
>
>
> How can cause maven-bundle-plugin to not export the org.test package? My
> understanding of the Private-Package header is that it doesn't export
> all the packages specified for it.
>

as per the online docs [1] the default Export-Package for v2.0.0 is:

   "<Export-Package> is now assumed to be the set of packages in your local
Java sources, excluding the default package '.' and any packages containing
'impl' or 'internal'."

also the description of Private-Package from earlier on the same page says:

   "If a package is selected by both the export and private package headers,
then the export takes precedence."

so if you only set Private-Package then you'll still have the default export
setting which will take precedence
(you can confirm this by using "mvn -X clean install" to output the final
processed instructions sent to BND)

because the default Private-Package now includes all the Java files under
"src/main/java" you could just use:

          <instructions>
            <Export-Package/>
          </instructions>

to make everything private - you'll still get the "org.test" package in your
bundle, but it won't be exported.

I guess we could make it so the default Export-Package is not used when
there's an explicit Private-Package,
but I typically prefer to have constant defaults (ie. not conditional on
other settings) which users then override
when they want different values

of course this particular situation isn't so straightforward because of the
precedence between export + private :(

[1]  http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html


> I've attached the project I am using. My maven version is 2.09.
>
> Thanks
> Chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>



-- 
Cheers, Stuart

Reply via email to