脚本如下(一些$引导的变量你自己可以在其他位置如properties文件中指定):
<target name="genkey">
<echo message="genkey..." />
<delete file="${basedir}/build/${keystore}" />
<!--delete file="${basedir}/build/${certification}" /-->
<genkey alias="${alias}" storepass="${storepass}" keystore="${basedir}/build/${keystore}" validity="3650" verbose="true">
<dname>
<param name="CN" value="${dname.CN}" />
<param name="OU" value="${dname.OU}" />
<param name="O" value="${dname.O}" />
<param name="L" value="${dname.L}" />
<param name="ST" value="${dname.ST}" />
<param name="C" value="${dname.C}" />
</dname>
</genkey>
<!--exec executable="keytool">
<arg line="-export" />
<arg line="-keystore ${keystore}" />
<arg line="-storepass ${storepass}" />
<arg line="-alias ${alias}" />
<arg line="-file ${basedir}/build/${certification}" />
</exec-->
<echo message="genkey...done." />
</target>
<target name="signjar" depends="genkey">
<echo message="jarsigner..." />
<!-- deleting this directory aim to sign all the jar files at the same time -->
<delete>
<fileset dir="${JarDir}">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
</delete>
<echo message="signed jar files deleted..." />
<signjar destDir="${JarDir}" alias="${alias}" keystore="${basedir}/build/${keystore}" storepass="${storepass}" verbose="true">
<path>
<fileset dir="${LibDir}" includes="**/*.jar,**/*.zip" />
<fileset dir="${SupportDir}" includes="**/*.jar,**/*.zip" />
</path>
<flattenmapper />
</signjar>
<delete file="${basedir}/build/${keystore}" />
<echo message="jarsigner...done." />
</target>