Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply the 'osgi' plugin, so the jar includes a bundle manifest. #98

Merged

Conversation

josephw
Copy link
Contributor

@josephw josephw commented Feb 26, 2015

This fixes #11. The plugin automatically determines Import-Package and
Export-Package based on analysis of the classes, and also adds
Tool, Bundle-Name, Bundle-Version, Bundle-SymbolicName and
others.

The manifest after this change looks like:

Manifest-Version: 1.0
Export-Package: org.hamcrest;version="2.0.0.0";uses:="javax.xml.namesp
 ace,org.hamcrest.collection,org.hamcrest.core,org.hamcrest.internal,o
 rg.w3c.dom",org.hamcrest.beans;version="2.0.0.0";uses:="org.hamcrest"
 ,org.hamcrest.collection;version="2.0.0.0";uses:="org.hamcrest",org.h
 amcrest.comparator;version="2.0.0.0";uses:="org.hamcrest",org.hamcres
 t.core;version="2.0.0.0";uses:="org.hamcrest",org.hamcrest.internal;v
 ersion="2.0.0.0";uses:="org.hamcrest",org.hamcrest.io;version="2.0.0.
 0";uses:="org.hamcrest",org.hamcrest.number;version="2.0.0.0";uses:="
 org.hamcrest",org.hamcrest.object;version="2.0.0.0";uses:="org.hamcre
 st",org.hamcrest.text;version="2.0.0.0";uses:="org.hamcrest",org.hamc
 rest.xml;version="2.0.0.0";uses:="javax.xml.namespace,org.hamcrest,or
 g.w3c.dom"
Implementation-Title: hamcrest-all
Implementation-Version: 2.0.0.0
Tool: Bnd-2.1.0.20130426-122213
Bundle-Name: java-hamcrest
Created-By: 1.7.0_25 (Oracle Corporation)
Implementation-Vendor: hamcrest.org
Bundle-Version: 2.0.0.0
Bnd-LastModified: 1424961114000
Bundle-ManifestVersion: 2
Import-Package: javax.xml.namespace,javax.xml.xpath,org.w3c.dom
Bundle-SymbolicName: org.hamcrest.java-hamcrest

which looks right.

This fixes hamcrest#11. The plugin automatically determines Import-Package and
Export-Package based on analysis of the classes, and also adds
Tool, Bundle-Name, Bundle-Version, Bundle-SymbolicName and
others.
@npryce
Copy link
Contributor

npryce commented Feb 26, 2015

I don't know enough about OSGi to judge. Any other OSGi users want to review this?

Or is there a way to write an automated test for the expected OSGi behaviour that this change will produce?

@josephw
Copy link
Contributor Author

josephw commented Feb 28, 2015

As a basic check, Apache Karaf offers a console. With that running,

karaf@root()> install file:///tmp/java-hamcrest-2.0.0.0.jar
Bundle ID: 49
karaf@root()> exports -p org.hamcrest
Package Name            | Version | ID | Bundle Name               
-------------------------------------------------------------------
org.hamcrest.beans      | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.collection | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.comparator | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.core       | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.internal   | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.io         | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.number     | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.object     | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.text       | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest.xml        | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest
org.hamcrest            | 2.0.0.0 | 49 | org.hamcrest.java-hamcrest

It would be possible to test this by writing something with, say, Felix or Equinox.

@mattbishop
Copy link

Can you mark the xml import packages as optional if they are only used for XML matching capabilities? That way you won't have to poke holes in your bootdelegation list to spark up hamcrest if one is not using XML

The only packages imported currently are XML packages only used for
optional functionality. Make the imports optional so the bundle can
be used without them being available.
Specifically list the packages that are optional. This won't affect the
current Import-Package, but it will mean that new additions don't surprise
by appearing as optional in future.
@josephw
Copy link
Contributor Author

josephw commented Sep 8, 2015

Good catch. I've updated the PR to make those imports optional:

Import-Package: javax.xml.namespace;resolution:=optional,javax.xml.xpa
 th;resolution:=optional,org.w3c.dom;resolution:=optional

@mattbishop
Copy link

👍

@sf105 sf105 merged commit cfaf873 into hamcrest:master Apr 7, 2016
@sf105 sf105 mentioned this pull request Apr 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hamcrest should be an osgi bundle
4 participants