Build.xml
<?xml version="1.0" encoding="UTF-8"?>
<projectname="en"basedir="."default="main">
<!-- 警告:只改这里的属性值,不要改其它的部分,以免出错。 -->
<propertyname="web.dir"value="iptven"/>
<propertyname="war.name"value="iptven.war"/>
<propertyname="src.dir"value="src"></property>
<propertyname="build.dir"value="build"></property>
<propertyname="jdk.version"value="1.6"/>
<targetname="clean">
<deletedir="${build.dir}"/>
<deletedir="${war.name}"/>
<deletefile="${war.name}.zip"/>
</target>
<!-- 读取更新文件列表,打补丁包的话需要。-->
<targetname="file2load"depends="clean">
<loadfileproperty="war.file.list"srcfile="changeList.txt"
failonerror="false"/>
<!--echo message="File contents is '${war.file.list}'"/-->
</target>
<!-- 编译,记得在前面修改编译版本。-->
<targetname="compile"depends="file2load">
<mkdirdir="${build.dir}"/>
<javacsource="${jdk.version}"target="${jdk.version}"
srcdir="${src.dir}"destdir="${build.dir}"encoding="UTF-8"
debug="on"debuglevel="lines,vars,source">
<classpath>
<filesetdir="${web.dir}/WEB-INF/lib"/>
</classpath>
</javac>
</target>
<!-- 文件列表不为空的话,就打补丁包。-->
<targetname="patch"depends="compile" if="war.file.list">
<mkdirdir="${war.name}"/>
<copytodir="${war.name}">
<filesetdir="${web.dir}"includesfile="changeList.txt"
excludes="**/*.jar"></fileset>
</copy>
<copytodir="${war.name}/WEB-INF/classes">
<filesetdir="${build.dir}"includesfile="changeList.txt"></fileset>
</copy>
</target>
<!-- 文件列表为空的话,就打全量包。这里没有用war任务,因为我们的项目不是打成标准war包。-->
<targetname="war"depends="compile"unless="war.file.list">
<mkdirdir="${war.name}"/>
<copydirdest="${war.name}"src="${web.dir}"excludes="**/*.jar"></copydir>
<copydirdest="${war.name}/WEB-INF/classes"src="${build.dir}"></copydir>
</target>
<!-- zip压缩-->
<targetname="zip"depends="patch,war">
<zipdestfile="${war.name}.zip">
<filesetdir="${basedir}"includes="${war.name}/**/*.*"/>
</zip>
</target>
<targetname="main"depends="zip">
<deletedir="${build.dir}"/>
<deletedir="${war.name}"/>
</target>
</project>
Batch.bat
del iptven.war.zip
xcopy /E iptven iptven.war\
jar cvMf iptven.war.zip iptven.war
rmdir /Q/S iptven.war
build.bat
call ant
pause