3

我尝试添加manifest.file=${src.dir}/manifest.mf到 project.properties,但是查看 build-impl.xml 我发现它manifest.available通常伴随着main.class条件,所以它让我相信只有当包有一个主类时才会添加我的清单,这是我的,作为图书馆,没有。无论我尝试什么,生成的库 jar 只包含自动生成的清单,其中只有 Ant-Version 和 Created-By。

4

2 回答 2

2

要获得易于编辑的 MANIFEST.MF,对上述内容进行修改是覆盖 build.xml 中的“-post-jar”任务,例如:

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

并创建包“META-INF”(也可用于其他调整,如“mime.types”文件)和其中一个名为“MANIFEST.MF”的空文件,然后可以在 NetBeans 编辑器中对其进行编辑,用于示例包含:

清单版本:1.0
福:酒吧
请参阅:Jar_File_Spec

这种方式经过测试:
产品版本:NetBeans IDE 6.9.1(内部版本 201011082200)
Java:1.6.0_21;Java HotSpot(TM) 64 位服务器 VM 17.0-b16
系统:在 amd64 上运行的 Linux 版本 2.6.32-29-generic;UTF-8;de_DE (nb)

于 2011-03-08T01:01:46.650 回答
2

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>
于 2009-10-23T02:45:53.617 回答