Markus
Markus

Reputation: 2053

How can I prevent jarsign script from overwriting existing Manifest values in signed jars?

I am building an Eclipse plugin which I want to deliver with signed jars.

After using Eclipse UI for creating the update site and building the plugins and features from there manually I want to sign the created jars.

Doing so leads to the manifests in the jars losing their OSGI metainformation attributes and thus in plugins not being found after restarting eclipse. Only signing information is left in the Jars' manifests.

I use this snippet to sign the artifacts, but I can reproduce this behaviour also with the JDK tool jarsign:

<signjar alias="${keystore.alias}" keystore="${keystore}"
          storepass="${keystore.password}"
          lazy="true" tsaurl="http://time.certum.pl/">
    <path>
        <path refid="plugins"/>
        <path refid="features"/>
    </path>
</signjar>

From the plugins I use the provided Manifests from the plugins like this one:

Bundle-ManifestVersion: 2
Bundle-Name: Tomcat Manager Plugin

How can I achieve that an existing Manifest is preserved while signing?

Upvotes: 1

Views: 133

Answers (1)

Markus
Markus

Reputation: 2053

I figured out that the plugin Manifest is not a "real" Manifest from a JDK perspective. A Manifest from JDK perspective needs to have the Attribute Manifest-Version in it. So the Manifest from the question should look like this:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tomcat Manager Plugin

If the Manifest look like this and now has the obviously mandatory attribute Manifest-Version, the jarsigner does its job like expected and preserves existing Manifest content.

Upvotes: 1

Related Questions