You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Florian Rampp <Fl...@web.de> on 2009/01/28 14:23:23 UTC

Export-Package header declaration for Felix Maven-Bundle-Plugin has unexpected behaviour

Hello!

I'm using the Maven-Bundle-Plugin and having problems with specifying export-package and import-package.

Since my package structure in java does not fit the default export-package (<groupId>.<artifactId>.*), I specify this on my own:
<plugin>
	<groupId>org.apache.felix</groupId>
	<artifactId>maven-bundle-plugin</artifactId>
	<extensions>true</extensions>
	<configuration>
		<instructions>
			<Export-Package>deus.model.*</Export-Package>
		</instructions>
	</configuration>
</plugin>

The effect is, that all packages are exported (good!) and that also, all packages contained in the bundle appear in the field Import-Package, although, they are contained in the bundle (not so good).
Why?

If I exclude the packages from this bundle from importing:
<plugin>
	<groupId>org.apache.felix</groupId>
	<artifactId>maven-bundle-plugin</artifactId>
	<extensions>true</extensions>
	<configuration>
		<instructions>
			<Export-Package>deus.model.*</Export-Package>
			<Import-Package>!deus.model.*,*</Import-Package>
		</instructions>
	</configuration>
</plugin>

All packages being in Import-Package before now appear in the header Ignore-Package (it's getting worse...). What is this header for?
I can't imagine how to simply export all classes of my package while not importing the packages contained in the bundle.

To further complicate this (actually not so complicated) issue, I would like to prevent everything inside an "impl" package from getting exported.
How to do this?
<Export-Package>!*.impl,deus.model.*</ExportPackage>
would fit my needs perfectly, but it looks like the wildcard * is only recognized at the end of a package path pattern.

I would really be glad, if somebody could help me, these issues really drive me crazy.

Thanks a lot!

Florian


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Export-Package header declaration for Felix Maven-Bundle-Plugin has unexpected behaviour

Posted by Florian Rampp <Fl...@web.de>.
Hello!

Thank you for your help, it now works.

For everybody, having similar problems, here is my
maven-bundle-plugin configuration.
Since the packages imported by my bundles are disjoint, I added
;-noimport:=true to Export-Package, but I will think more about
whether this is good.


<!-- don't remove properties, even if they are empty!!! -->
<properties>
<osgi.rootPackage>deus.storage</osgi.rootPackage>
<osgi.additionalPackageImports>org.springframework.orm.jpa.support</osgi.additionalPackageImports>
<osgi.nonExportedPackages>!*.impl</osgi.nonExportedPackages>
</properties>

...
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>

<!--
export all packages below the root package (except non exported
packages), and don't reimport them! more on importing exported
packages here:
http://www.osgi.org/blog/2007/04/importance-of-exporting-nd-importing.html
-->
<Export-Package>${osgi.nonExportedPackages},${osgi.rootPackage}.*;-noimport:=true</Export-Package>

<!--
include all other packages (also the non exported packages!) as
private. Export-Package takes precedence over Private-Package!
-->
	
<Private-Package>${osgi.rootPackage}.*;-split-package:=merge-first</Private-Package>

<!--
remove the BND internal header, that just states, which packages are
ignored by BND
-->
<_removeheaders>Ignore-Package</_removeheaders>

<!-- add additional package imports -->
<Import-Package>${osgi.additionalPackageImports},*</Import-Package>

</instructions>
</configuration>
</plugin>



Bye,

Florian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Export-Package header declaration for Felix Maven-Bundle-Plugin has unexpected behaviour

Posted by Arjun Panday <ar...@alcatel-lucent.fr>.
Florian,

I believe that part of the answer to your problem is explained in 
section 3.5.6 "Exporting and Importing a Package" of the core OSGi spec, 
which states that "Bundles should import exported packages, allowing the 
resolver to substitute packages that contain interfaces and other shared 
types."

A condensed explanation by Rick Hall is also available here:
http://felix.apache.org/site/apache-felix-osgi-faq.html#ApacheFelixOSGiFAQ-Shouldabundleimportitsownexportedpackages%253F

Arjun.



Florian Rampp wrote:
> Hello!
>
> I'm using the Maven-Bundle-Plugin and having problems with specifying export-package and import-package.
>
> Since my package structure in java does not fit the default export-package (<groupId>.<artifactId>.*), I specify this on my own:
> <plugin>
> 	<groupId>org.apache.felix</groupId>
> 	<artifactId>maven-bundle-plugin</artifactId>
> 	<extensions>true</extensions>
> 	<configuration>
> 		<instructions>
> 			<Export-Package>deus.model.*</Export-Package>
> 		</instructions>
> 	</configuration>
> </plugin>
>
> The effect is, that all packages are exported (good!) and that also, all packages contained in the bundle appear in the field Import-Package, although, they are contained in the bundle (not so good).
> Why?
>
> If I exclude the packages from this bundle from importing:
> <plugin>
> 	<groupId>org.apache.felix</groupId>
> 	<artifactId>maven-bundle-plugin</artifactId>
> 	<extensions>true</extensions>
> 	<configuration>
> 		<instructions>
> 			<Export-Package>deus.model.*</Export-Package>
> 			<Import-Package>!deus.model.*,*</Import-Package>
> 		</instructions>
> 	</configuration>
> </plugin>
>
> All packages being in Import-Package before now appear in the header Ignore-Package (it's getting worse...). What is this header for?
> I can't imagine how to simply export all classes of my package while not importing the packages contained in the bundle.
>
> To further complicate this (actually not so complicated) issue, I would like to prevent everything inside an "impl" package from getting exported.
> How to do this?
> <Export-Package>!*.impl,deus.model.*</ExportPackage>
> would fit my needs perfectly, but it looks like the wildcard * is only recognized at the end of a package path pattern.
>
> I would really be glad, if somebody could help me, these issues really drive me crazy.
>
> Thanks a lot!
>
> Florian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Export-Package header declaration for Felix Maven-Bundle-Plugin has unexpected behaviour

Posted by Stuart McCulloch <mc...@gmail.com>.
2009/1/28 Florian Rampp <Fl...@web.de>

> Hello!
>
> I'm using the Maven-Bundle-Plugin and having problems with specifying
> export-package and import-package.
>
> Since my package structure in java does not fit the default export-package
> (<groupId>.<artifactId>.*), I specify this on my own:
> <plugin>
>        <groupId>org.apache.felix</groupId>
>        <artifactId>maven-bundle-plugin</artifactId>
>        <extensions>true</extensions>
>        <configuration>
>                <instructions>
>                        <Export-Package>deus.model.*</Export-Package>
>                </instructions>
>        </configuration>
> </plugin>
>
> The effect is, that all packages are exported (good!) and that also, all
> packages contained in the bundle appear in the field Import-Package,
> although, they are contained in the bundle (not so good).
> Why?
>
> If I exclude the packages from this bundle from importing:
> <plugin>
>        <groupId>org.apache.felix</groupId>
>        <artifactId>maven-bundle-plugin</artifactId>
>        <extensions>true</extensions>
>        <configuration>
>                <instructions>
>                        <Export-Package>deus.model.*</Export-Package>
>                        <Import-Package>!deus.model.*,*</Import-Package>
>                </instructions>
>        </configuration>
> </plugin>
>
> All packages being in Import-Package before now appear in the header
> Ignore-Package (it's getting worse...). What is this header for?
> I can't imagine how to simply export all classes of my package while not
> importing the packages contained in the bundle.
>
> To further complicate this (actually not so complicated) issue, I would
> like to prevent everything inside an "impl" package from getting exported.
> How to do this?
> <Export-Package>!*.impl,deus.model.*</ExportPackage>
> would fit my needs perfectly, but it looks like the wildcard * is only
> recognized at the end of a package path pattern.
>
> I would really be glad, if somebody could help me, these issues really
> drive me crazy.
>

re. your exports also being imported - this is a specific feature of the Bnd
Tool, see:


http://www.osgi.org/blog/2007/04/importance-of-exporting-nd-importing.html

as well as:

   http://aqute.biz/Code/Bnd#export-package

which explains how to turn this off (add -noimport:=true as an attribute on
the package)
but importing your exports shouldn't cause any problems - on the contrary it
solves them!

Ignore-Package is just a 'helper/documentation' entry so you can see what
packages the
Bnd Tool ignored (same as the Include-Resource and Private-Package entries)
these can
be removed from the final bundle as the OSGi framework doesn't use them - if
you want to
remove them use the <_removeheaders> instruction, also documented on the Bnd
site.

the Bnd site also explains how Export-Package is processed (left to right)
... so to export
your public API but not your implementation packages, use something like the
following:

   <Export-Package>!deus.model.impl.*,deus.model.*"</Export-Package>
   <Private-Package>deus.model.impl.*</Private-Package>

HTH

Thanks a lot!
>
> Florian
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
-- 
Cheers, Stuart