Skip to content

OSGi Support #33

@swimmesberger

Description

@swimmesberger

It would be nice when the jar would contain OSGi metadata so we could directly consume it via maven central without doing any wrapping.
I have seen this project uses ant to build. I'm not familiar with ant (only gradle/maven) so I can't provide a pull request for generating OSGi metdata but I can guide you into the right direction.
First I would recommend BND - BND is a tool which automatically generates a MANIFEST.MF containing all the necessary OSGi metdata based on the compiled *.class files. BND can be used with gradle, maven and ant to analyze the class files and generate the corresponding MANIFEST.MF based on them and a instructions file (e.g. bnd.bnd). This bnd.bnd file tells bnd what it should do.
In your case:
Bundle-SymbolicName: com.github.seancfoley.ipaddress
Export-Package: inet.ipaddr.*

would be probably enough.

Here I have also found a BND ant example: https://groups.google.com/forum/#!topic/bndtools-users/UgQ9bmoU4Eg

The final MANIFEST.MF should look roughly something like that:

Manifest-Version: 1.0
Automatic-Module-Name: com.github.seancfoley.ipaddress
Bnd-LastModified: 1581504821138
Bundle-ManifestVersion: 2
Bundle-Name: com.github.seancfoley.ipaddress
Bundle-SymbolicName: com.github.seancfoley.ipaddress
Bundle-Version: 5.2.1
Created-By: 1.8.0_202-ea (Oracle Corporation)
Export-Package: inet.ipaddr;uses:="inet.ipaddr.format,inet.ipaddr.form
 at.standard,inet.ipaddr.format.string,inet.ipaddr.format.util,inet.ip
 addr.format.util.sql,inet.ipaddr.format.validate,inet.ipaddr.ipv4,ine
 t.ipaddr.ipv6,inet.ipaddr.mac";version="5.2.1",inet.ipaddr.format;use
 s:="inet.ipaddr,inet.ipaddr.format.standard,inet.ipaddr.format.string
 ,inet.ipaddr.format.util";version="5.2.1",inet.ipaddr.format.large;us
 es:="inet.ipaddr,inet.ipaddr.format,inet.ipaddr.format.string,inet.ip
 addr.format.util";version="5.2.1",inet.ipaddr.format.standard;uses:="
 inet.ipaddr,inet.ipaddr.format,inet.ipaddr.format.string,inet.ipaddr.
 format.util,inet.ipaddr.format.validate";version="5.2.1",inet.ipaddr.
 format.string;uses:="inet.ipaddr,inet.ipaddr.format.util";version="5.
 2.1",inet.ipaddr.format.util;uses:="inet.ipaddr,inet.ipaddr.format,in
 et.ipaddr.format.standard,inet.ipaddr.format.string,inet.ipaddr.forma
 t.util.sql";version="5.2.1",inet.ipaddr.format.util.sql;uses:="inet.i
 paddr.format.string,inet.ipaddr.format.util";version="5.2.1",inet.ipa
 ddr.format.validate;uses:="inet.ipaddr,inet.ipaddr.format,inet.ipaddr
 .format.standard,inet.ipaddr.mac";version="5.2.1",inet.ipaddr.ipv4;us
 es:="inet.ipaddr,inet.ipaddr.format,inet.ipaddr.format.standard,inet.
 ipaddr.format.string,inet.ipaddr.format.util,inet.ipaddr.ipv6";versio
 n="5.2.1",inet.ipaddr.ipv6;uses:="inet.ipaddr,inet.ipaddr.format,inet
 .ipaddr.format.standard,inet.ipaddr.format.string,inet.ipaddr.format.
 util,inet.ipaddr.ipv4,inet.ipaddr.mac";version="5.2.1",inet.ipaddr.ma
 c;uses:="inet.ipaddr,inet.ipaddr.format,inet.ipaddr.format.standard,i
 net.ipaddr.format.string,inet.ipaddr.format.util,inet.ipaddr.ipv6";ve
 rsion="5.2.1"
Import-Package: inet.ipaddr,inet.ipaddr.format,inet.ipaddr.format.larg
 e,inet.ipaddr.format.standard,inet.ipaddr.format.string,inet.ipaddr.f
 ormat.util,inet.ipaddr.format.util.sql,inet.ipaddr.format.validate,in
 et.ipaddr.ipv4,inet.ipaddr.ipv6,inet.ipaddr.mac
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-4.3.1.201911131708

It is possible to simply "hardcode" the manifest additions like that but that would mean that if packages are added you would have to manually maintain that hardcoded manifest too. Some stuff listed above is also optional and only produced because bnd produces "super correct" manifests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions