Search code examples
javaantcode-signing

How can I check a signed jar file using Ant?


I sign jar files with the Ant signjar task and now I want to test before deploy.

I can check with

jarsigner -verify sbundle.jar 

but I do not know if it is possible to do the same with Ant?


Solution

  • An alternative would be to base your build on a maven script.
    Maven does propose the jarsigner:verify plugin

    If that is not a valid possibility, you still can use the Exec Ant task to directly call the jarsigner command. If the return code is correctly set, you can add the attribute failonerror (Stop the build process if the command exits with a return code other than 0.)