<?xml version="1.0" encoding="ISO-8859-1"?><!-- Copyright 2004 camry.wu@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA--><project name="Common build file" default="all" basedir=""><description> 这是一个通用的 ant build 文件. Version 1.0. 感谢: 这篇文档借用了很多 Johan 的想法, 他的主页在 http://dev.kanngard.net Copyright 2004 camry.wu@gmail.com</description><!-- 读入 common.xml 配置 --><xmlpropertyfile="${path.common}/common.xml" semanticAttributes="true" keepRoot="false"/><!-- 设置编译时的 classpath --><path id="compile.classpath"> <fileset dir="${path.common}/lib"><include name="*.jar"/> </fileset> <fileset dir="${lib}"><include name="*.jar"/> </fileset> <pathelement location="${dist.classes}"/></path><!-- 设置运行时的 classpath --><path id="run-time.classpath"> <path refid="compile.classpath"/></path><!-- 初始化过程, 会调用具体项目的初始化过程先 --><target name="init" depends="project_init" description="Initialize environment"></target><!-- 显示使用说明 --><target name="usage"> <loadfile property="usage.message"srcFile="${path.common}/usage.txt"/> <echo message="${usage.message}"/></target><!-- 预备, 通常在项目刚建立的时候运行此任务 --><target name="common_prepare" depends="init" description="Prepare build directory"> <copy todir="." preservelastmodified="true"><fileset dir="${path.common}/template/"><include name="**/*"/></fileset> </copy></target><!-- 配置 checkstyle , 只检查 src/main 目录下的源代码 --><target name="checkstyle" depends="init"> <taskdefresource="checkstyletask.properties"classpath="${path.common}/lib/checkstyle-all-3.4.jar"/> <checkstyle config="${build}/checkstyle_checks.xml"><fileset dir="${src.main}" includes="**/*.java"/><property key="checkstyle.cache.file" file="${path.common}/lib/checkstyle.cache"/><classpath refid="compile.classpath"/> </checkstyle></target><!-- 编译 src 下源文件, class 文件放到 dist/classes 下 --><target name="compile" depends="init" description="Compile source"> <mkdir dir="${dist}/classes"/> <javacdebug="${compile.debug}"deprecation="${compile.deprecation}"destdir="${dist}/classes"target="${compile.jdk-version.target}"source="${compile.jdk-version.source}"optimize="${compile.optimize}"srcdir="${src}"><classpath refid="compile.classpath"/> </javac></target><!-- 清除 dist 目录 --><target name="clean" depends="project_clean" description="Wipeout all generated files"> <delete dir="${dist}/classes"/> <delete dir="${dist.lib}"/> <mkdir dir="${dist}/classes"/> <mkdir dir="${dist.lib}"/></target><!-- 打包 --><target name="jar" depends="checkstyle, compile" description="Create binary distribution"> <mkdir dir="${dist}/classes"/> <mkdir dir="${dist.lib}"/> <copy file="LICENSE" todir="${dist}/classes"/> <delete><fileset dir="${dist.lib}" includes="*.jar"/> </delete> <jarbasedir="${dist}/classes" jarfile="${dist.lib}/${component.name}-${component.version}.jar"><include name="**/*.class"/><exclude name="**/Test*.class"/> </jar> <delete><fileset dir="${dist}/classes"><include name="LICENSE"/></fileset> </delete></target><!-- 运行 dist/classes 目录下的所有以 Test 开头的测试类 --><target name="test" depends="compile" description="run junit tests"> <junit printsummary="on"fork="false"haltonfailure="false"failureproperty="tests.failed"showoutput="true"><classpath refid="run-time.classpath"/><formatter type="brief" usefile="false"/><batchtest><fileset dir="${dist}/classes"> <include name="**/Test*.*"/></fileset></batchtest> </junit> <fail if="tests.failed"> ********************************************************* ********************************************************* ****One or more tests failed! Check the output...**** ********************************************************* ********************************************************* </fail></target><!-- 发布, 会调用具体项目的发布任务 --><target name="deploy" depends="project_deploy" description="Deploy application"/><!-- 创建文档 --><target name="javadoc" depends="compile" description="Create component Javadoc documentation"> <delete dir="${docs.api}"/> <mkdir dir="${docs.api}"/> <javadocauthor="true"bottom="${component.title}"destdir="${docs.api}"source="${compile.jdk-version.source}"doctitle="${component.title}"packagenames="*"access="protected"sourcepath="${src.main}"version="true"windowtitle="${component.title} (Version ${component.version})"><classpath refid="compile.classpath"/> </javadoc></target><!--根据 cvs 配置, 从 cvs 服务器上下载源代码 --><target name="fetch" depends="project_fetch" description="fetch current source from cvs"></target><!-- 将源代码文件打包, 备份 --><target name="src-zip" depends="checkstyle,compile" description="Creates source distribution"> <copy file="LICENSE" todir="${src.main}"/> <delete><fileset dir="${dist.lib}" includes="*-src.zip"/> </delete> <zipbasedir="." destfile="${dist.lib}/${component.name}-${component.version}-src.zip" whenempty="fail"><include name="**/*.*"/><include name="*"/><include name="**/*"/><exclude name="${dist}/**/*.*"/><exclude name="*.*~"/><!-- vi(JEdit) backups --><exclude name=".nbattrs"/><!-- Netbeans filesystem attributes --><exclude name="*.old"/> </zip></target><!-- 将源文件上传到服务器备份, 将目标文件上传到服务器发布. 此任务中内容由各位自行设定, 一般是运行 ftp 任务.--><target name="publish" depends="clean,jar,javadoc,src-zip" description="publish project"></target><!-- 构建 --><target name="all" depends="clean,fetch,test,jar,javadoc,deploy" description="build project"/></project> |