简体   繁体   English

如何在不覆盖MANIFEST.MF内容的情况下使用Ant签署OSGi包?

[英]How can I sign an OSGi bundle with Ant without overwriting the MANIFEST.MF contents?

I have an Eclipse plugin for which I create the OSGi bundle JARs with Ant. 我有一个Eclipse插件,我使用Ant创建了OSGi包JAR。 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. 我想用Ant任务签名,但是用类签名覆盖MANIFEST.MF内容,使得OSGi包无法使用。 The JDK jarsigner tool has the same behavior. JDK jarsigner工具具有相同的行为。 The Eclipse PDE seems to have that functionality, but as far as I know you can only use it from within Eclipse. Eclipse PDE似乎具有该功能,但据我所知,您只能在Eclipse中使用它。 I want to be able to run my Ant build from the command line. 我希望能够从命令行运行我的Ant构建。 Does anybody know of a simple way to append the class signatures to MANIFEST.MF instead of overwriting it? 有没有人知道将类签名附加到MANIFEST.MF而不是覆盖它的简单方法?

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=

This seems to be a JDK issue. 这似乎是一个JDK问题。 With 1.5.0_16 , the jarsigner overwrites my existing MANIFEST.MF, but with 1.6.0_13 everything works fine. 随着1.5.0_16 ,jarsigner覆盖我现有的MANIFEST.MF,但是1.6.0_13一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM