3

I tried adding manifest.file=${src.dir}/manifest.mf to project.properties, but looking through the build-impl.xml I see that the manifest.available is usually accompanied by main.class condition, so it makes me believe that my manifest would be added only if the package has a main class, which mine, being a library, does not have. No matter what I tried, the resulting library jar contains just the auto-generated manifest with only Ant-Version and Created-By.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
  • Do you have access to the jar generation command/or are you able to modify/tweak/override it. Then you could just use your own manifest for the jar'ing. – Peter Kofler Oct 21 '09 at 07:13

2 Answers2

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>
martin clayton
  • 76,436
  • 32
  • 213
  • 198
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
2

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)

Michael Besteck
  • 2,415
  • 18
  • 10