跨平臺的xml腳本引擎,用於自動化調用程序完成項目的編譯,大包,測試,通常命名爲build.cml,能夠設置一些列target。css
target通常包括:html
<project name="項目名" default="默認的運行目標" basedir="" description="項目的描述"> <property file="build.properties" /> <property name="xxxxJarPath" value="${tempPath}/xxxx.jar" /> <property name="xxxxBuildPath" value="${tempPath}/xxxxBuildPath" /> <property name="xxxxClassPath" value="${xxxxBuildPath}/classes" /> <property name="xxxLibPath" value="${ProjectPath}/web/WEB-INF/lib" /> <property name="webPath" value="${ProjectPath}/web" /> <property name="webDest" value="${tempPath}/xxxx-web" /> <property name="webDestZip" value="${tempPath}/xxxx-web/xxx.zip" /> <target name="clean"> <delete dir="${xxxxBuildPath}" /> </target> <!--depends爲依賴的target,執行target前會執行depends target --> <target name="build" depends="clean"> <!--建立class path--> <mkdir dir="${xxxxClassPath}" /> <!--編譯class文件--> <javac destdir="${xxxxClassPath}" encoding="UTF-8"><!--class輸出路徑--> <src path="${xxxxSrcPath}" /><!--原文件路徑--> <classpath refid="xxxLibPath" /><!--支持的lib文件的路徑--> </javac> </target> <!--建立jar --> <target name="create_xxxx_jar" depends="build"> <jar destfile="${xxxxJarPath}" filesetmanifest="mergewithoutmain"> <manifest> <attribute name="Main-Class" value="Utils.xxxxUtils" /> <attribute name="Class-Path" value="." /> </manifest> <fileset dir="${xxxxClassPath}" /> <zipfileset excludes="META-INF/*.xx" src="${xxxLibPath}/poi-3[1].0.1-FINAL-.jar" /> </jar> </target> <!--該標籤用來執行編譯生成的.class文件 --> <target name="run_xxxx" depends="create_xxxx_jar"> <!--fork在一個新的虛擬機中運行該類 --> <java jar="${xxxxJarPath}" fork="true"> <arg line="${webPath} ${webDest} ${xxxxResourse}" /> <sysproperty key="file.encoding" value="utf-8" /> </java> </target> <!--copy靜態文件,包括css,image,jsp/html --> <target name="copyStaticFile" depends="run_xxxx"> <copy todir="${webDest}/css"> <fileset dir="${webPath}/css" /> </copy> <copy todir="${webDest}/images"> <fileset dir="${webPath}/images" /> </copy> <copy todir="${webDest}/js"> <fileset dir="${webPath}/js" /> </copy> <copy todir="${webDest}"> <fileset dir="${webDest}/html" /> </copy> <delete dir="${webDest}/html" /> </target> <!--將靜態文件打包--> <target name="staticFileZip" depends="copyStaticFile"> <zip destfile="${webDestZip}"> <fileset dir="${webDest}" /> </zip> </target> <target name="MapperXMLCopy" depends="staticFileZip"> <copy todir="${xxxxClassPath}"> <fileset dir="${ProjectPath}/src" excludes="*.java,*/*.java,*/*/*.java,*/*/*/*.java,*/*/*/*/*.java,*/*/*/*/*/*.java,*/*/*/*/*/*/*.java,*/*/*/*/*/*/*/*.java" /> </copy> </target> <!--copy 配置文件--> <target name="webCopy" depends="MapperXMLCopy"> <copy todir="${webDest}/META-INF"> <fileset dir="${ProjectPath}/web/META-INF"/> </copy> <copy todir="${webDest}/WEB-INF"> <fileset file="${ProjectPath}/web/WEB-INF/*.xml"/> </copy> </target> <!--打成war包--> <target name="war" depends="webCopy"> <war destfile="${tempPath}/xxxx.war" webxml="${MProjectPath}/web/WEB-INF/web.xml"> <fileset dir="${webDest}"/> <lib dir="${xxxLibPath}"/> <classes dir="${xxxxClassPath}" /> </war> </target> <!--將war包放到jboss或者tomcat目錄下--> <target name="moveWar" depends="war"> <move todir="${xxxxWarDestPath}"> <fileset file="${tempPath}/xxxx.war"/> </move> </target> </project>