pikopong

it's all about knowledge

Automatically Sign JARs using Ant and Bash

with 2 comments

This guide is more towards Netbeans project, but it can be used as a reference for you to customize the script to suit your needs.

The signer bash file:

1
2
3
4
#!/bin/bash
find . -name "*.jar" -exec jarsigner -keystore /path/to/your/key -storepass yourpassword '{}' yourkeystorename \;
echo 'JARs signed';
exit 0

This script will actually search all files ending with .jar from the current directory recursively and then sign it. This means, it can be used separately without ant script. Just make it executeable and run it.

Put this in the last line of your build.xml but it must before the closing tag of the “project” (build.xml can be found in your main project directory)

1
2
3
4
5
6
7
8
<project>
    .
    .
    .
    <target name="-post-jar">
        <exec dir="${dist.dir}" executable="/path/to/your/signer" os="Linux" />
    </target>
</project>

This script will basically sign the jars after all the jars has been build. Please note that it’s better if you set all the path using absolute type of path.

After this, you just have to use Clean and Build to automatically generate the JARs and also automatically sign it. This script will also sign all of your libraries. Good luck :)

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • PDF
  • Print
  • Reddit
  • Slashdot
  • Technorati
  • Twitter

Related Posts

Written by amree

April 14th, 2008 at 8:48 am

Posted in programming

Tagged with , , , ,

2 Responses to 'Automatically Sign JARs using Ant and Bash'

Subscribe to comments with RSS or TrackBack to 'Automatically Sign JARs using Ant and Bash'.

  1. /path/to/your/key

    didn’t understand this argument.
    what should be here.
    path to ks file or path to .cer file ?

    abcNo Gravatar

    27 Apr 10 at 02:32 PM

  2. @abc

    It’s the path to your generated key (keystore)

    amreeNo Gravatar

    27 Apr 10 at 02:42 PM

Leave a Reply