Ant task to remove signature from jar file

This article suggest an Ant macro that removes the publisher signature from an java .jar file, also known as to ‘unsign’ a jar.

    <macrodef name="unsignjar">
        <attribute name="jarFile" />
            <jar update="yes"
                <zipfileset src="@{jarFile}">
                    <include name="**"/>
                    <exclude name="META-INF/*.SF"/>
                    <exclude name="META-INF/*.DSA"/>
                    <exclude name="META-INF/*.RSA"/>
            <move file="@{jarFile}.tmp" 
                  overwrite="true" />

An example how to call the macro.

    <target ...>
        <unsignjar jarFile="hibernate.jar" />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: