Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding manifest properties to existing jar files with ant

Tags:

java

ant

Since the latest java release (7u45), I'm getting tons of errors on third part jar libraries that my webstart application uses, due to newly required manifest attributes being missing:

Missing Application-Name: manifest attribute for: http://site/lib/jh.jar
Missing Permissions manifest attribute for: http://site/lib/jh.jar
Missing Codebase manifest attribute for: http://lib/jh.jar

So, I need to run a batch ant task to update the manifest files in each of the 30 or so required libraries before I can use them for distribution.

How can I do this in ant? (preferably without ant-contrib)

PS: I've already fixed all the other 7u45 update crap (code signing, JNLP attribs, etc).

like image 305
Judd Avatar asked Nov 20 '13 22:11

Judd


People also ask

How do I change the manifest of a JAR file?

To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest. Warning: The text file from which you are creating the manifest must end with a new line or carriage return.

Where do I put manifest file in Jar?

The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections.

How do you update a manifest file?

Testing manifest updates # Plug in the device and ensure it's connected to WiFi. Use the Android task manager to shut down the PWA, then use the App panel in Android settings to force stop the PWA. In Chrome, open about://webapks and click the "Update" button for the PWA. "Update Status" should change to "Pending".


1 Answers

Try something like this.

   <for param="jarFile">
        <fileset dir="${webapp.dir}">
            <include name="*.jar"/>
        </fileset>
        <sequential>
            <jar update="true" file="@{jarFile}">
                <manifest>
                    <attribute name="Application-Name" value="ABCDEF"/>
                    <attribute name="Codebase" value="*"/>
                    <attribute name="Permissions" value="all-permissions"/>
                </manifest>
            </jar>
        </sequential>
    </for>
like image 71
preetham Avatar answered Oct 13 '22 00:10

preetham