ant build.xml
<project basedir="." default="usage" name="myceaas"><target name="init">
<property name="Name" value="myceaas" />
<property name="name" value="myceaas" />
<property name="version" value="0.2" />
<property name="year" value="2006" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<property name="debug" value="off" />
<property name="optimize" value="on" />
<property name="deprecation" value="on" />
<!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />-->
<!-- java源文件路径 -->
<property name="src.dir" value="${basedir}/src" />
<!-- jar包路径 -->
<property name="lib.dir" value="${basedir}/myceaas/WEB-INF/lib" />
<!-- webapp路径 -->
<property name="webapp.dir" value="${basedir}/myceaas" />
<property name="packages" value="com.ce.myceaas.*" />
<!-- 准备源文件路径 -->
<property name="build.src" value="${basedir}/AntBuild/build" />
<!-- 编译源文件路径 -->
<property name="build.dest" value="${basedir}/AntBuild/bin" />
<!-- 准备webapp文件路径 -->
<property name="buildwar.dest" value="${basedir}/AntBuild/warsrc" />
<!-- 准备javadoc文件路径 -->
<property name="build.javadocs" value="${basedir}/AntBuild/doc" />
<!-- 打包jar文件路径 -->
<property name="jar.dest" value="${basedir}/AntBuild/jar" />
<!-- 打包war文件路径 -->
<property name="war.dest" value="${basedir}/AntBuild/war" />
<!-- resin-home路径 -->
<property name="resin.home" value="C:\resin-pro-3.0.17"/>
<!-- tomcat-home路径 -->
<property name="tomcat.home" value="C:\tomcat5.5.12"/>
<property name="j2eelib.dir" value="C:/Program Files/MyEclipse/eclipse/plugins/com.genuitec.eclipse.j2eedt.core_3.9.210/data/libraryset/1.4" />
<!-- classpath -->
<path id="classpath">
<fileset dir="${j2eelib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<!--<pathelement location="lib/"/>-->
</path>
<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message=" available targets are:" />
<echo message="" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" build --> compiles the source code" />
<echo message=" javadoc --> generates the API documentation" />
<echo message=" clean --> cleans up the directory" />
<echo message="" />
<echo message=" Please rename build.properties.default to build.properties" />
<echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
<echo message="" />
<echo message=" See the comments inside the build.xml file for more details." />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message="" />
</target>
<!-- =================================================================== -->
<!-- 准备源文件-->
<!-- =================================================================== -->
<target name="prepare-src" depends="init">
<!-- create directories -->
<mkdir dir="${build.src}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${jar.dest}" />
<mkdir dir="${war.dest}" />
<mkdir dir="${buildwar.dest}" />
<!-- copy src files -->
<copy todir="${build.src}">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${buildwar.dest}">
<fileset dir="${webapp.dir}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- 编译源文件-->
<!-- =================================================================== -->
<target name="build" depends="prepare-src">
<javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
<classpath refid="classpath" />
</javac>
<copy todir="${buildwar.dest}/WEB-INF/classes">
<fileset dir="${build.src}" >
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- 打war包-->
<!-- =================================================================== -->
<target name="myceaas.war" depends="build">
<war warfile="${war.dest}/myceaas.war" webxml="${buildwar.dest}/WEB-INF/web.xml">
<lib dir="${buildwar.dest}/WEB-INF/lib"/>
<classes dir = "${buildwar.dest}/WEB-INF/classes"/>
<fileset dir="${buildwar.dest}">
</fileset>
</war>
</target>
<!-- =================================================================== -->
<!-- 发布到本的resin和tomcat-->
<!-- =================================================================== -->
<target name="publish" depends="myceaas.war,clean">
<copy todir="${resin.home}/webapps">
<fileset dir="${war.dest}" >
<include name="**/*.war"/>
</fileset>
</copy>
<copy todir="${tomcat.home}/webapps">
<fileset dir="${war.dest}" >
<include name="**/*.war"/>
</fileset>
</copy>
</target>
<!--
<target name="SyncMain">
<java classname="com.ce.synchronization.main.SyncMain" failonerror="true" fork="yes">
<classpath refid="classpath"/>
</java>
</target>
-->
<!-- =================================================================== -->
<!-- 产生javadoc api 文档-->
<!-- =================================================================== -->
<target name="javadoc" depends="build">
<mkdir dir="${build.javadocs}" />
<javadoc packagenames="${packages}" sourcepath="${build.src}" destdir="${build.javadocs}" author="true" version="true" use="true" splitindex="true" windowtitle="${Name} API" doctitle="${Name}">
<classpath refid="classpath" />
</javadoc>
</target>
<!-- =================================================================== -->
<!-- 清除临时文件-->
<!-- =================================================================== -->
<target name="clean" depends="init">
<delete dir="${build.src}"/>
<delete dir="${build.dest}/org"/>
<delete dir="${build.dest}/com"/>
<delete dir="${buildwar.dest}"/>
<delete>
<fileset dir="${build.dest}" includes="**/*.class"/>
</delete>
</target>
</project>