最近一直用JB2005,发现里面一个头痛的bug,一个project build完后你会发现在WEB-INF/classes里面的class文件没有更新。于是一怒之下就下了下面这个build文件,主要实现了编译,打包和部署,改改里面的路径就好。
<!--
Alex Luo's ant module
-->
<project name="SWX Project" default="all" basedir=".">
<property name="src.code" value="src"/>
<property name="tomcat.home" value="C:/Tomcat 5.0/common/lib"/>
<property name="proj.dir" value="Reprot"/>
<property name="lib.dir" value="${proj.dir}/WEB-INF/lib"/>
<property name="deploy.dir" value="F:\tools\jboss-4.0.0\jboss-4.0.0\server\default\deploy"/>
<property name="deploy.name" value="swx30"/>
<property name="proj.war" value="${deploy.name}.war"/>
<property name="dist.root" value="${proj.dir}/WEB-INF/classes"/>
<!-- out doc -->
<property name="doc.dir" value="doc"/>
<property name="doc.api" value="${doc.dir}/api"/>
<property name="javadoc.package" value="com.*"/>
<!-- classpath -->
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${tomcat.home}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="init">
<mkdir dir="${dist.root}"/>
<tstamp/>
<echo message="${TSTAMP}"></echo>
</target>
<target name="all" depends="clean,compile,deploy"/>
<!-- -->
<target name="compile" depends="init">
<javac destdir="${dist.root}" deprecation="off">
<src path="${src.code}"/>
<classpath refid="classpath"/>
</javac>
<jar jarfile="${proj.war}" basedir="${proj.dir}">
<include name="**/**"/>
</jar>
</target>
<target name="deploy">
<delete file="${deploy.dir}/${proj.war}"/>
<copy file="${proj.war}" todir="${deploy.dir}"/>
</target>
<!-- generate javadoc -->
<target name="javadoc" depends="init">
<mkdir dir="${doc.api}"/>
<javadoc packagenames="${javadoc.package}" sourcepath="${src.code}"
private="yes" defaultexcludes="yes" destdir="${doc.dir}/api">
<classpath refid="classpath"/>
</javadoc>
</target>
<!-- compile junit -->
<target name="compilejunit" depends="compile">
<mkdir dir="${dist.junit}"/>
<javac destdir="${dist.junit}" deprecation="on">
<src path="${src.junit}"/>
<classpath refid="classpath"/>
<classpath refid="proj.libs"/>
</javac>
</target>
<!-- execute junit -->
<target name="junit" depends="compilejunit">
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<path refid="classpath"/>
<pathelement location="${dist.junit}"/>
</classpath>
<formatter type="plain"/>
<!-- test name="com.TestClassTest" haltonfailure="no" outfile="result"/ -->
<batchtest todir="${dist.junit}">
<fileset dir="${dist.junit}" includes="**/Test*.class" />
</batchtest>
</junit>
</target>
<!-- delete old file -->
<target name="clean">
<delete dir="${dist.root}"/>
</target>
</project>