<?xml version="1.0" ?> <project name="生成doc文档"> <property name="src.dir" location="src" ></property> <property name="build.dir" location="build" ></property> <property name="build.classes.dir" location="${build.dir}/classes" ></property> <property name="doc.dir" location="doc" ></property> <property name="zip_name" value="ant_doc.zip"></property> <property name="zip.dir" location="zip"></property> <property name="project_name" value="ant_doc"></property> <target name="clean"> <delete dir="${build.dir}"></delete> <mkdir dir="${build.dir}"/> <mkdir dir="${build.classes.dir}"/> <mkdir dir="${doc.dir}"/> <mkdir dir="${zip.dir}"/> </target> <!-- 编译源文件 --> <target name="compile" depends="clean"> <javac srcdir="${src.dir}" destdir="${build.classes.dir}" failonerror="true"></javac> </target> <!-- 生成doc文档 (不依赖于编译) --> <target name="build-doc"> <javadoc sourcepath="${src.dir}" package="com.zf.*" destdir="${doc.dir}" private="true" charset="UTF-8" docencoding="UTF-8" encoding="UTF-8"> <classpath path="${build.classes.dir}"></classpath> </javadoc> </target> <!-- 打包 --> <target name="zip" depends="compile,build-doc" > <zip destfile="${zip.dir}/${zip_name}" duplicate="preserve" > <!-- prefix指定在指定文件夹下加入文件 --> <zipfileset dir="${src.dir}" includes="**/*.*" prefix="${project_name}/src"> </zipfileset> <zipfileset dir="${doc.dir}" includes="**/*.*" prefix="${project_name}/doc/api" > </zipfileset> </zip> </target> </project>