I have an Eclipse plugin for which I create the OSGi bundle JARs with Ant. I would like to sign them with the Ant task, but that overwrites the MANIFEST.MF contents with the class signatures, making the OSGi bundles unusable. The JDK jarsigner tool has the same behavior. The Eclipse PDE seems to have that functionality, but as far as I know you can only use it from within Eclipse. I want to be able to run my Ant build from the command line. Does anybody know of a simple way to append the class signatures to MANIFEST.MF instead of overwriting it?
Asked
Active
Viewed 998 times
2 Answers
2
I don't think the manifest is overwritten by default. Observe the following console script:
$ touch MyMainClass.class
$ echo 'Main-Class: MyMainClass' > MyManifest
$ jar cvmf MyManifest myjar.jar MyMainClass.class
added manifest
adding: MyMainClass.class(in = 0) (out= 0)(stored 0%)
$ unzip -c myjar.jar META-INF/MANIFEST.MF
Archive: myjar.jar
inflating: META-INF/MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.6.0_17 (Apple Inc.)
Main-Class: MyMainClass
$ jarsigner myjar.jar mykeyid
Enter Passphrase for keystore:
$ unzip -c myjar.jar META-INF/MANIFEST.MF
Archive: myjar.jar
inflating: META-INF/MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.6.0_17 (Apple Inc.)
Main-Class: MyMainClass
Name: MyMainClass.class
SHA1-Digest: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=

marcprux
- 9,845
- 3
- 55
- 72
-
I tried it again and still my MANIFEST.MF is overwritten. I am on Windows XP though. – FelixM Dec 10 '09 at 16:08
-
I am stumped, now it works. Maybe something went wrong when the JARs were created. – FelixM Dec 11 '09 at 00:46
-
What does your manifest look like? I wonder if the OSGi package declarations in the manifest are being overwritten by jarsigner's. – marcprux Dec 11 '09 at 00:46
2
This seems to be a JDK issue. With 1.5.0_16
, the jarsigner overwrites my existing MANIFEST.MF, but with 1.6.0_13
everything works fine.

FelixM
- 1,496
- 1
- 9
- 19