1、projecthome.cmd
set PROJECT_HOME=
2、cpappend.cmd
set CLASSPATH=%LIB_HOME%/%1;%CLASSPATH%
3、build.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE project [<!ENTITY buildfile SYSTEM "file:./build-user.xml">]>
<!-- WARNING: Eclipse autogenerated file.
Any modifications will be overwritten.
Please edit build-user.xml instead.
-->
<project default="final" name="***系統">
<!--定義指向目錄的快捷符號-->
<property environment="env"/>
<property name="PRJ.SRC" value="${env.PROJECT_HOME}/src"/>
<property name="PRJ.EXTSRC" value="${env.PROJECT_HOME}/src from projecting/"/>
<property name="PRJ.TEMP" value="${env.PROJECT_HOME}/temp"/>
<property name="PRJ.LIB" value="${env.PROJECT_HOME}/lib"/>
<property name="PRJ.PERSISTENT" value="${env.PROJECT_HOME}/PERSISTENT"/>
<!--初始化TEMP目錄,以便儲存編譯後的檔案 -->
<target name="init">
<echo message="Initalizing..."/>
<delete dir="${PRJ.TEMP}"/>
<mkdir dir="${PRJ.TEMP}"/>
<delete >
<fileset dir="${PRJ.PERSISTENT}">
<include name="**/*.*" />
</fileset>
</delete>
</target>
<!--編譯PRJ.SRC檔案夾下的Java檔案,產生class檔案,存放在臨時檔案夾下-->
<target depends="init" name="build">
<echo message="Building... "/>
<javac srcdir="${PRJ.SRC}/"
destdir="${PRJ.TEMP}/"
debug="true"
encoding="UTF-8">
<classpath >
<fileset dir="${PRJ.LIB}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<!-- 測試 -->
<target name="test" depends="build" description="run junit test">
<echo>下面開始測試${PRJ.TEMP}</echo>
<fail if="tests.failed">
</fail>
</target>
<!--將臨時檔案夾下的檔案打包,存放在PRJ.PERSISTENT-->
<target name="pack" depends="build,resource" >
<jar compress="false" destfile="${PRJ.PERSISTENT}/persistent.jar">
<fileset dir="${PRJ.TEMP}">
<include name="**/*.*"/>
</fileset>
</jar>
</target>
<!--執行結束後刪除臨時檔案夾-->
<target name="final" depends="pack">
<echo message="Deleting..."/>
<delete dir="${PRJ.TEMP}"/>
</target>
<!--把原檔案中的一些資源檔複製到臨時檔案夾中,以便打包-->
<target name="resource" depends="init">
<copy todir="${PRJ.TEMP}">
<fileset dir="${PRJ.SRC}">
<include name="**/*.jpe"/>
<include name="**/*.jpeg"/>
<include name="**/*.rmf"/>
<include name="**/*.wav"/>
<include name="**/*.mid"/>
<include name="**/*.midi"/>
<include name="**/*.au"/>
<include name="**/*.gif"/>
<include name="**/*.png"/>
<include name="**/*.jpg"/>
<include name="**/*.aiff"/>
<include name="**/*.properties"/>
<include name="**/*.xml"/>
<include name="**/*.swf"/>
</fileset>
</copy>
</target>
</project>
4、build.cmd
@echo off
rem 擷取當前路徑
copy projecthome.cmd temp.cmd>nul
cd..
cd >>builder/temp.cmd
cd builder
call temp.cmd
del temp.cmd
echo 當前路徑為 %PROJECT_HOME%
rem set JAVA_HOME=%PROJECT_HOME%/java/jdk1.5.0_02
rem set JDK_HOME=%PROJECT_HOME%/java/jdk1.5.0_02
rem set JRE_HOME=%PROJECT_HOME%/java/jre1.5.0_02
set ANT_HOME=%PROJECT_HOME%/ant
set LIB_HOME=%PROJECT_HOME%/lib
set CLASSPATH=%JDK_HOME%/lib/tools.jar
set path=%ANT_HOME%/bin;%path%
echo adding all jar in lib directory
for %%i in (../lib/*.jar) do call cpappend %%i
@echo on
ant