Kisho
Kisho

Reputation: 11

OSGi: Recalculate the Import-Package of a JAR programmatically

I want to recalculate the "Import-Package" of an OSGi Jar programmatically. I try to use the bnd Analyser.

    try(Analyzer analyzer = new Analyzer()) {
        analyzer.setJar(new File(filename));
        return analyzer.getImportPackage();
    }

This returns the (wrong) existent imports of the MANIFEST.MF. How can I recalculate the "Import-Package" of an OSGi Jar programmatically?

Update Adding as BJ Hargrave calMainfest() suggested does not work:

try(Analyzer analyzer = new Analyzer()) {
    analyzer.setJar(new File(filename));
    analyzer.calcManifest(); 
    return analyzer.getImportPackage();
}

It seems to use the existing MANIFEST.MF contained in the Jar. Best regards Kisho

Upvotes: 0

Views: 78

Answers (1)

BJ Hargrave
BJ Hargrave

Reputation: 9384

You need to call calcManifest() to compute a new manifest. Otherwise it just uses the existing manifest.

Upvotes: 0

Related Questions