我有一个Eclipse插件,可以使用Ant为它创建OSGi捆绑JAR.我想用Ant任务对其进行签名,但这会用类签名覆盖MANIFEST.MF内容,从而使OSGi捆绑包无法使用. JDK jarsigner工具具有相同的行为. Eclipse PDE似乎具有该功能,但是据我所知,您只能在Eclipse中使用它.我希望能够从命令行运行我的Ant构建.有人知道将类签名附加到MANIFEST.MF而不是覆盖它的简单方法吗?
解决方法:
我认为清单默认不会被覆盖.观察以下控制台脚本:
$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=
标签:osgi,jarsigner,java,ant
来源: https://codeday.me/bug/20191107/2002145.html