Is it possible to add a custom manifest to a Java library compiled in Netbeans 6.7.1?

白昼怎懂夜的黑 提交于 2019-12-06 00:35:50
Remus Rusanu

I ended up adding a Jar task in the build.xml, which was really good since it allowed me to add a Sign task also after the manifest update:

<target name="-post-jar">
    <jar destfile="${dist.jar}"
        update="true">
       <manifest>
         <attribute name="Built-By" value="..."/>
         <attribute name="Specification-Title" value="..."/>
         <attribute name="Specification-Vendor" value="..."/>
         <attribute name="Specification-Version" value="..."/>
         <attribute name="Implementation-Vendor" value="..."/>
         <attribute name="Implementation-Title" value="..."/>
         <attribute name="Implementation-Version" value="..."/>
       </manifest>
    </jar>
    <signjar jar="${dist.jar}"
        alias="..."
        keystore="..."
        storepass="..."/>
</target>
Michael Besteck

To get an easy to edit MANIFEST.MF a modification of the above is to override the "-post-jar" task in build.xml like:

<target name="-post-jar">
        <jar destfile="${dist.jar}"
        update="true" manifest="src/META-INF/MANIFEST.MF">
        </jar>
</target>

and to create the package "META-INF" (may also be used for other adjustments like a "mime.types" file) and therein an empty file named "MANIFEST.MF", which then can be edited inside the NetBeans editor, for example containing:

Manifest-Version: 1.0
Foo: Bar
See: Jar_File_Spec

This way tested with:
Product Version: NetBeans IDE 6.9.1 (Build 201011082200)
Java: 1.6.0_21; Java HotSpot(TM) 64-Bit Server VM 17.0-b16
System: Linux version 2.6.32-29-generic running on amd64; UTF-8; de_DE (nb)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!