<?xml version="1.0" encoding="UTF-8"?>
<project name="MakeTopoJar" default="deployTopoJar" basedir=".">
<!-- 设定系统环境变量名为env,以备下边使用 -->
<property environment="env"/>
<!-- 设定构建JAR时的路径与文件名参数,注意:下边的属性设定时,如果属性代表路径,则为了适应相应操作系统可用location代替value;
如果属性代表文件名,则必须用value. -->
<property name="src" value="./src" />
<property name="webRoot" location="WebRoot"/>
<property name="webInf" location="${webRoot}/WEB-INF"/>
<property name="destDir" location="${webInf}/classes"/>
<property name="classPath" location="${webInf}/lib"/>
<property name="topoJarPath" location="${webRoot}/topo/lib"/>
<property name="jarName" value="topo.jar"/>
<!-- 数字签名用的密钥信息参数 -->
<property name="keystoreName" value="esmkeystore"/>
<property name="storepass" value="esmsystem"/>
<property name="keystore" location="${topoJarPath}/${keystoreName}"/>
<property name="keypass" value="esmsystem"/>
<property name="keysize" value="1024"/>
<property name="alias" value="esmkey"/>
<property name="validity" value="365"/>
<property name="jarsigner" value="${env.JAVA_HOME}/bin/jarsigner.exe"/>
<!-- 部署数字签名后的JAR到TOMCAT相应目录 -->
<property name="deployJarPath" location="${env.TOMCAT_HOME}/webapps/QT_ESM/topo/lib"/>
<target name="build">
<mkdir dir="${destDir}" />
<javac failonerror="false" encoding="utf-8" nowarn="true" debug="true" optimize="on" srcdir="${src}"
destdir="${destDir}" includes="com/quantanetwork/esm/**/*.java, org/acegisecurity/ui/webapp/**/*.java">
<classpath>
<fileset dir="${classPath}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<!-- 构建JAR文件 -->
<target name="makeJar" depends="build">
<copy todir="${destDir}/classes">
<fileset dir="${src}">
<include name="com/quantanetwork/esm/ui/topo/show/icons/*.*" />
</fileset>
</copy>
<jar jarfile="${topoJarPath}/${jarName}" basedir="${destDir}"
includes="com/quantanetwork/esm/logic/topo/**, com/quantanetwork/esm/ui/topo/**">
</jar>
</target>
<!-- 创建证书 -->
<target name="genericKey">
<echo message="genkey..."/>
<delete>
<fileset dir="${topoJarPath}">
<include name="${keystoreName}"/>
</fileset>
</delete>
<genkey keystore="${keystore}" storepass="${storepass}" alias="${alias}" keypass="${keypass}" keysize="${keysize}"
verbose="true" validity="${validity}" dname="CN=Ant Group, OU=Jakarta Division, O=Apache.org, C=ZH">
</genkey>
<echo message="genkey... done"/>
</target>
<!-- 对JAR进行数字签名 -->
<target name="signJar" depends="makeJar, genericKey">
<echo message="jarsigner..." />
<exec executable="${jarsigner}" dir="${topoJarPath}">
<arg line="-keystore"/>
<arg value="${keystore}"/>
<arg line="-storepass"/>
<arg value="${storepass}"/>
<arg line="${jarName}"/>
<arg line="${alias}"/>
</exec>
<!-- 下边这种方式也可以 -->
<!--signjar keystore="${keystore}" storepass="esmsystem" jar="${jarName}" alias="${alias}">
<fileset dir="${topoJarPath}">
<include name="${jarName}" />
</fileset>
</signjar-->
<echo message="jarsigner... done." />
</target>
<!-- 部署JAR文件 -->
<target name="deployTopoJar" depends="signJar">
<copy todir="${deployJarPath}" file="${topoJarPath}/${jarName}">
</copy>
</target>
</project>