分為兩部份:
1. build.sh
2. build.xml
《build.sh》
#!/bin/bash
# ---------------------------------------------------------------
#
#
# ---------------------------------------------------------------
# define variables
export ANT_HOME=/app/build/ant-1.8.1
export BUILD_HOME=/app/build
export BUILD_FILE=$BUILD_HOME/build.xml
#target=$1
$ANT_HOME/bin/ant -buildfile $BUILD_FILE
《build.xml》
<!--basedir 代表執行目錄為當前所在目錄,default 屬性代表預設執行的 target 區塊之 name-->
<project name="nova" basedir="." default="make-dist">
<!--property標籤用來設定變數,目前範例為設定備用的目錄路徑-->
<property name="src.dir" value="/app/build/nova/src" />
<property name="src.resource.dir" value="${src.dir}/src/main/resource/" />
<property name="target.dir" value="/app/build/nova/target" />
<property name="dist.dir" value="/app/build/nova/dist" />
<property name="backup.dir" value="/app/build/nova/bakup" />
<target name="update-src">
<!--log information from svn and stop build if there is any error -->
<exec executable="svn" spawn="false" failonerror="true">
<arg line="update --username svnreader --password svnreader ${src.dir}" />
</exec>
</target>
<target name="prepare">
<delete dir="${backup.dir}" />
<mkdir dir="${target.dir}" />
<mkdir dir="${backup.dir}" />
<copy todir="${backup.dir}">
<fileset dir="${target.dir}" />
</copy>
</target>
<target name="clean" depends="prepare">
<delete includeemptydirs="true">
<fileset dir="${target.dir}" includes="**/*" />
</delete>
</target>
<target name="compile-src" depends="update-src, prepare, clean">
<javac srcdir="${src.dir}" destdir="${target.dir}" debug="on" optimize="off" deprecation="on">
<classpath>
<fileset dir="${src.dir}/lib">
<include name="*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="make-dist" depends="compile-src">
<copy todir="${dist.dir}">
<fileset dir="${target.dir}" />
</copy>
<copy todir="${dist.dir}">
<fileset dir="${src.resource.dir}">
<include name="**/*.vm/**" />
</fileset>
</copy>
</target>
</project>
http://itgroup.blueshop.com.tw/Gpx1981/gpx1981?n=convew&i=8916