2009/5/11 David Jencks <[email protected]>

> Lets start over.
>
> I'd like an way to get a package version for the packages in a bundle into
> the Export-Packages and Import-Packages when using the maven-bundle-plugin
> 2.0.0 or later, preferably without writing out these entries in the plugin
> configuration.  Also, the behavior of this plugin appears to have changed
> radically between 1.4.3 and 2.0.0 and configurations that used to produce
> reasonable results now produce nonsense.
>

Hi David,

the "nonsense" results only occur when people have relied on unspec'd
behaviour in earlier versions,
namely that "provided" scope dependencies are not on the project classpath
passed to the BND tool.
(this behaviour was not intended and was a side-effect of a Maven setting
used by the bundleplugin)

some projects mis-used this behaviour and put
<Export-Package>*</Export-Package> in their poms
as a simple way to include and export all the packages in the project - any
build dependencies they
didn't want in the final bundle they then marked as "provided" scope

in the 2.0.0 release there was a conscious decision (discussed on this list)
to change this behaviour
so that the complete compilation classpath would be passed to the BND tool -
the reason for this was
because omitting dependencies from the classpath meant that BND didn't have
the complete picture
and could not then augment imports with the right dependency versions.

this is covered in the FAQ:


http://felix.apache.org/site/apache-felix-bundle-plugin-faq.html#ApacheFelixBundlePluginFAQ-WhydoIseemoreclassesinmybundleafterupgradingtomavenbundleplugin2.0.0
?

and is the reason why we bumped the major version up to 2

I'll only show the manifest entries of interest to save space.
>
> First, supplying no configuration produces reasonable results that only
> lack the version for the packages in the bundle:
>
> configuration:
>        <plugin>
>          <groupId>org.apache.felix</groupId>
>          <artifactId>maven-bundle-plugin</artifactId>
>          <version>2.0.0</version>
>          <extensions>true</extensions>
>          <configuration>
>            <instructions>
>           </instructions>
>          </configuration>
>        </plugin>
>

correct - version 2.0.0 detects packages in the local sources and configures
the bundleplugin accordingly.

we yet don't check for the specification version in the manifest config /
source, but this would be possible
- if you'd like automatic versioning of local packages please open a feature
request (not a bug) on JIRA


> manifest entries;
> Export-Package: javax.portlet.filter;uses:="javax.portlet,javax.xml.na
>  mespace,javax.servlet.http,org.w3c.dom",javax.portlet;uses:="javax.xm
>  l.namespace,javax.servlet.http,org.w3c.dom"
> Import-Package: javax.portlet,javax.portlet.filter,javax.servlet.http;
>  version="2.5",javax.xml.namespace,org.w3c.dom
>
> What I'd like is some way to specify the version of the javax.portlet and
> javax.portlet.filter packages in the Export-Package and Import-Package
> headers without altering the uses clauses in the Export-Package header.
>
> I imagine the result would look something like this:
> Export-Package: javax.portlet.filter;uses:="javax.portlet,javax.xml.na
>
>  
> mespace,javax.servlet.http,org.w3c.dom";version="2.0",javax.portlet;uses:="javax.xm
>  l.namespace,javax.servlet.http,org.w3c.dom";version="2.0"
> Import-Package:
> javax.portlet;version="2.0",javax.portlet.filter;version="2.0",javax.servlet.http;
>  version="2.5",javax.xml.namespace,org.w3c.dom
>
> ----------------------------------------------------
> I tried copying the  configuration style used in the geronimo spec bundles.
>
> configuration:
>  <properties>
>    <portals.osgi.import.pkg>*</portals.osgi.import.pkg>
>    <portals.osgi.export.pkg>*</portals.osgi.export.pkg>


^ this is an example of using "*" to include and export everything on the
classpath passed to BND
if you want to get the same behaviour in 2.0.0 while using "*" then add this
configuration setting:

  <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <configuration>
      <excludeDependencies>*;scope=provided|runtime</excludeDependencies>
    </configuration>
  </plugin>

which should remove the bogus entries by hiding provided and runtime
dependencies from BND

the alternative is to be more explicit in your instructions:


<Export-Package>javax.portlet.*;version=${portals.osgi.export.version}</Export-Package>

which tells BND to export all packages under javax.portlet using the given
version

   <portals.osgi.private.pkg/>
>
>  
> <portals.osgi.export>!META-INF*,${portals.osgi.export.pkg}*;version=${portals.osgi.export.version}</portals.osgi.export>
>    <portals.osgi.export.version>2.0</portals.osgi.export.version>
>
>  
> <portals.osgi.import>!META-INF*,${portals.osgi.import.pkg}</portals.osgi.import>
>    <portals.osgi.symbolic.name>${groupId}.${artifactId}</
> portals.osgi.symbolic.name>
>    <bnd.version.policy>$(version;==;$(@))</bnd.version.policy>
>  </properties>
> ...
>        <plugin>
>          <groupId>org.apache.felix</groupId>
>          <artifactId>maven-bundle-plugin</artifactId>
>          <version>2.0.0</version>
>          <extensions>true</extensions>
>          <configuration>
>            <instructions>
>              <Export-Package>${portals.osgi.export}</Export-Package>
>              <Import-Package>${portals.osgi.import}</Import-Package>
>              <Private-Package>${portals.osgi.private.pkg}</Private-Package>
>              <_versionpolicy>${bnd.version.policy}</_versionpolicy>
>            </instructions>
>          </configuration>
>        </plugin>
>
> manifest entries:
> Export-Package: javax.servlet;version="2.0",javax.portlet.filter;uses:
>  ="javax.portlet,javax.xml.namespace,javax.servlet.http,org.w3c.dom";v
>  ersion="2.0",javax.portlet;uses:="javax.xml.namespace,javax.servlet.h
>  ttp,org.w3c.dom";version="2.0",javax.servlet.http;uses:="javax.servle
>  t";version="2.0",javax.servlet.resources;version="2.0"
> Import-Package: javax.portlet;version="2.0",javax.portlet.filter;versi
>  on="2.0",javax.servlet;version="2.5",javax.servlet.http;version="2.5"
>  ,javax.servlet.resources;version="2.5",javax.xml.namespace,org.w3c.do
>  m
>
> There are several problems with this that I can see:
> - too many imports


note that the default is to import whatever is exported (not just packages
from other bundles)


http://felix.apache.org/site/apache-felix-osgi-faq.html#ApacheFelixOSGiFAQ-Shouldabundleimportitsownexportedpackages
?


> - exports include all imports, not just stuff in the bundle itself


actually you'll probably find that all exported packages are in the bundle
(use "jar tvf ...")
because BND doesn't just zip up "target/classes" like the jar-plugin,
instead it pulls files
from the entire classpath according to your instructions


> - version 2.0 is applied to all exports, even the imports that are imported
> with a different version.
>

correct, because with this setup all dependencies are passed to BND so it
can detect
the dependency version and apply this to imported packages - however,
because you
are using "*;version=2.0" to export, then all packages will be sucked into
the bundle
and then explicitly exported as version 2.0 (as you requested in your
instructions)

If I go back to 1.4.3 I get more reasonable results:
>
> configuration:
> same as above except using plugin v. 1.4.3
>
> manifest entries:
>
> Export-Package: javax.portlet.filter;uses:="javax.portlet,org.w3c.dom,
>  javax.servlet.http,javax.xml.namespace";version="2.0",javax.portlet;u
>  ses:="org.w3c.dom,javax.servlet.http,javax.xml.namespace";version="2.
>  0"
> Import-Package: javax.portlet;version="2.0",javax.portlet.filter;versi
>  on="2.0",javax.servlet.http,javax.xml.namespace,org.w3c.dom
>
> The only problem I see here is that the import of the servlet package
> doesn't have a version.
>

these imports don't have a version because they come from provided
dependencies,
which aren't passed to BND in version 1.4.3 - this is exactly why we changed
it round
that the complete classpath is sent to BND, then your imports get the
correct versions

executive summary:

  1) don't export  *  unless you really want everything in your bundle

  2) use something like  my.specific.domain.*;version="my.version"

  3) consider using <_versionpolicy> to add automatic import ranges

remember to raise a feature request if you want automatic versioning of
local source ;)

HTH

---------------------------------------------------------------
>
> Just in case anyone reads this far, I reiterate: my goal is to specify the
> version of the packages in the current bundle and have this show up in the
> Export-Packages and Import-Packages headers, something like this:
>
> Export-Package: javax.portlet.filter;uses:="javax.portlet,javax.xml.na
>
>  
> mespace,javax.servlet.http,org.w3c.dom";version="2.0",javax.portlet;uses:="javax.xm
>  l.namespace,javax.servlet.http,org.w3c.dom";version="2.0"
> Import-Package:
> javax.portlet;version="2.0",javax.portlet.filter;version="2.0",javax.servlet.http;
>  version="2.5",javax.xml.namespace,org.w3c.dom
>
> Do I have to write out these headers in their entirety in the plugin
> configuration or is there some way to simply add the version to the
> automatically generated headers?
>
> thanks
> david jencks
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Cheers, Stuart

Reply via email to