<?xml version="1.0" encoding="GB2312"?> <!-- ======================================== --> <!-- 标准构建文件 v1.3.0 --> <!-- 使用前请修改: --> <!-- 项目名称 --> <!-- ======================================== -->
<!-- ======================================== --> <!-- [project_name] 构建文件 --> <!-- auther: --> <!-- date : @build_date@ --> <!-- ======================================== -->
<project name="[project_name]" basedir="./" default="build"> <!-- 记录构建时间 --> <tstamp> <format property="exedate" pattern="yyyy-MM-dd" /> <format property="exetime" pattern="hh:mm:ss" /> </tstamp> <!-- ================================================= --> <!-- 项目名称、版本,用于创建文件名 --> <property name="Name" value="[big_project_name]" /> <property name="name" value="[small_project_name]" /> <property name="name2" value="[short_project_name]" /> <!-- 版本号:[主版本-次版本-修订号] --> <property name="version.major" value="1" /> <property name="version.minor" value="0" /> <property name="version.patch" value="0" />
<!-- 版本号: 无修订号 --> <property name="version.sansPatchLevel" value="${version.major}.${version.minor}" /> <!-- 版本号:完整版本号 --> <property name="version.full" value="${version.sansPatchLevel}.${version.patch}" /> <!-- 完整名称 --> <property name="fullname" value="${name}-${version.full}" /> <!-- ant构建文件名 --> <property name="buildfile" value="build.xml" /> <!-- jar包名 --> <property name="jar.file" value="${fullname}.jar" /> <!-- ================================================= -->
<!-- 源代码目录 --> <property name="src.dir" value="src" /> <property name="etc.dir" value="conf" /> <property name="bin.dir" value="bin" /> <property name="lib.dir" value="lib" /> <property name="jdbc.dir" value="${lib.dir}" /> <property name="class.dir" value="classes" /> <!-- 文档目录 --> <property name="doc.dir" value="doc" /> <property name="doc.api.dir" value="${doc.dir}/api" /> <property name="doc.ref.dir" value="${doc.dir}/reference" /> <!-- 示例路径源代码目录 --> <property name="example.dir" value="examples" /> <!-- 测试用例源代码目录 --> <property name="testcase.dir" value="test" /> <!-- ====================================== -->
<!-- 目标根目录 --> <property name="dist.root" value="dist" /> <property name="dist.dir" value="${dist.root}/${fullname}" /> <!-- 目标目录 --> <property name="dist.src.dir" value="${dist.dir}/src" /> <property name="dist.etc.dir" value="${dist.dir}/conf" /> <property name="dist.bin.dir" value="${dist.dir}/bin" /> <property name="dist.lib.dir" value="${dist.dir}/lib" /> <property name="dist.jdbc.dir" value="${dist.dir}/lib" /> <property name="dist.class.dir" value="${dist.dir}/classes" /> <!-- 目标文档目录 --> <property name="dist.doc.dir" value="${dist.dir}/doc" /> <property name="dist.api.dir" value="${dist.dir}/doc/api" /> <property name="dist.ref.dir" value="${dist.dir}/doc/reference" />
<!-- 示例目标目录 --> <property name="dist.example.dir" value="${dist.dir}/examples" /> <!-- 测试用例源代码目录 --> <property name="dist.testcase.dir" value="${dist.dir}/test" /> <!-- ===================================== -->
<!-- 配置选项:如果构建时不需要,请注释掉 -->
<!-- 复制jar包开关 --> <property name="switch.copyjar" value="" /> <!-- 复制bin开关 --> <property name="switch.copybin" value="" /> <!-- 复制etc配置文件开关 --> <property name="switch.copyetc" value="" /> <!-- 复制jdbc驱动开关 --> <property name="switch.copyjdbc" value="" /> <!-- 复制库文件开关 --> <property name="switch.copylib" value="" /> <!-- 复制示例文件开关 --> <property name="switch.copyexample" value="" /> <!-- 复制测试用例开关 --> <!--property name="switch.copytestcase" value="" /--> <!-- ======================================== -->
<!-- JDBC驱动列表 --> <fileset id="jdbc.list" dir="${lib.dir}"> <include name="**/*.jar" /> </fileset> <!-- 外部库列表 --> <fileset id="lib.list" dir="${lib.dir}"> <include name="**/*.jar" /> </fileset> <!-- CLASSPATH --> <path id="classpath"> <fileset dir="${lib.dir}"> <include name="**/*.jar" /> </fileset> </path> <!-- ========================================== --> <!-- java编译配置 --> <property name="javadoc" value="http://java.sun.com/j2se/1.4/docs/api" /> <property name="javac.debug" value="on" /> <property name="javac.optimize" value="off" /> <property name="javac.target" value="1.4" /> <property name="javac.source" value="1.4" /> <property name="javac.deprecation" value="on" /> <property name="javac.compiler" value="modern" /> <!-- ========================================= --> <!-- ==== --> <!-- ========================================= -->
<filter token="year" value="${year}" /> <filter token="version.full" value="${version.full}" /> <filter token="date" value="${TODAY}" /> <filter token="log" value="true" /> <filter token="verbose" value="true" /> <patternset id="jar.files"> <include name="**/*.dtd" /> <include name="**/*.xml" /> <include name="**/*.xslt" /> </patternset> <patternset id="src.files"> <!-- include everything we want in the src directory that we didn't want in the jar itself --> <include name="**/*.java" /> </patternset> <patternset id="refdoc.files"> <include name="**/*.css" /> <include name="**/*.jpg" /> <include name="**/*.gif" /> <include name="**/*.png" /> </patternset> <!-- =============================================== --> <!-- ==== 使用帮助 --> <!-- =============================================== --> <target name="usage"> <echo>${Name} Build file ------------------------------------------------------------- available targets are: jar - generates the ${Name}.jar file build - compiles the source code javadoc - generates the API documentation clean - cleans up the directory dist - will create a complete distribution in dist Setting the env variable NO_JAVADOC will build the distribution without running the javadoc target. release - will create a complete distribution in dist using stricter settings for public distribution. Please rename build.properties.default to build.properties and edit build.properties to specify JSDK 2.3 classpath. See the comments inside the build.xml file for more details. -------------------------------------------------------------</echo> </target> <!-- ============================================ --> <!-- ==== 构建 --> <!-- ============================================ --> <!-- ==== 创建API文档 =========================== --> <target name="javadoc"> <mkdir dir="${src.dir}" /> <mkdir dir="${doc.api.dir}" /> <javadoc sourcepath="${src.dir}" destdir="${doc.api.dir}" author="true" version="true" use="true" splitindex="true" windowtitle="${Name} API" doctitle="${Name}"> <!-- link="${javadoc}"--> <classpath refid="classpath" /> <packageset dir="${src.dir}" defaultexcludes="yes"> <include name="**" /> </packageset> <group title="Core API" packages="com.zjw.*" /> </javadoc> </target> <!-- ==== 编译源代码 ============================= --> <target name="build"> <mkdir dir="${src.dir}" /> <mkdir dir="${class.dir}" /> <javac srcdir="${src.dir}" destdir="${class.dir}" debug="${javac.debug}" optimize="${javac.optimize}"> <classpath refid="classpath" /> </javac> </target> <!-- ==== 创建jar包 ============================== --> <target name="jar" depends="build"> <mkdir dir="${lib.dir}" /> <jar jarfile="${lib.dir}/${jar.file}" basedir="${class.dir}" includes="**" /> </target>
<!-- ==== 清理目标 =============================== --> <target name="clean"> <delete dir="${dist.dir}" /> </target> <!-- ==== 清理全部目标 =========================== --> <target name="clean-all"> <delete dir="${class.dir}" /> <delete dir="${doc.api.dir}" /> <delete dir="${dist.root}" /> </target> <!-- =========================================== --> <!-- ==== 构建发行版本 --> <!-- =========================================== --> <!-- ==== 创建源代码 ======================= --> <target name="build-src"> <mkdir dir="${dist.src.dir}" /> <copy todir="${dist.src.dir}"> <fileset dir="${src.dir}" /> </copy> </target>
<!-- ==== 创建项目文档 ================== -->
<target name="build-doc" depends="javadoc">
<mkdir dir="${dist.doc.dir}" />
<copy todir="${dist.doc.dir}">
<fileset dir="${doc.dir}" />
</copy>
</target>
<!-- ==== 创建jar包 ======================= --> <target name="build-jar" depends="jar" if="switch.copyjar"> <mkdir dir="${dist.lib.dir}" /> <copy file="${lib.dir}/${jar.file}" todir="${dist.lib.dir}" /> </target> <!-- ==== 复制etc目录中配置文件 ============ --> <target name="build-etc" if="switch.copyetc"> <mkdir dir="${etc.dir}" /> <mkdir dir="${dist.etc.dir}" /> <copy todir="${dist.etc.dir}"> <fileset dir="${etc.dir}" /> </copy> </target>
<!-- ==== 复制bin目录中执行文件 ============ --> <target name="build-bin" if="switch.copybin"> <mkdir dir="${bin.dir}" /> <mkdir dir="${dist.bin.dir}" /> <copy todir="${dist.bin.dir}"> <fileset dir="${bin.dir}" /> </copy> </target> <!-- ==== 复制jdbc驱动 ==================== --> <target name="build-jdbc" if="switch.copyjdbc"> <mkdir dir="${jdbc.dir}" /> <mkdir dir="${dist.jdbc.dir}" /> <copy todir="${dist.jdbc.dir}"> <fileset refid="jdbc.list" /> </copy> </target> <!-- ==== 复制lib库文件 ==================== --> <target name="build-lib" if="switch.copylib"> <mkdir dir="${lib.dir}" /> <mkdir dir="${dist.lib.dir}" /> <copy todir="${dist.lib.dir}"> <fileset refid="lib.list" /> </copy> </target>
<!-- ==== 复制示例 ======================== --> <target name="build-example" if="switch.copyexample"> <mkdir dir="${example.dir}" /> <mkdir dir="${dist.example.dir}" /> <copy todir="${dist.example.dir}"> <fileset dir="${example.dir}" /> </copy> </target> <!-- ==== 复制测试用例 ==================== --> <target name="build-testcase" if="switch.copytestcase"> <mkdir dir="${testcase.dir}" /> <mkdir dir="${dist.testcase.dir}" /> <copy todir="${dist.testcase.dir}"> <fileset dir="${testcase.dir}" /> </copy> </target> <!-- ==== 构建发行版本 - 无javadoc ========== --> <target name="dist" depends="build-src,build-jar,build-etc,build-bin,build-jdbc,build-lib,build-example,build-testcase"> <echo message="${exedate} ${exetime}" /> <!-- 复制ANT配置文件 --> <copy file="${buildfile}" todir="${dist.dir}" /> </target> <!-- ==== 构建发行版本 ====================== --> <target name="release" depends="build-src,build-doc,build-jar,build-etc,build-bin,build-jdbc,build-lib,build-example,build-testcase"> <echo message="${exedate} ${exetime}" /> <!-- 复制ANT配置文件 --> <copy file="${buildfile}" todir="${dist.dir}" /> </target> <!-- =========================================== --> <!-- ==== 扩展任务 --> <!-- =========================================== --> <!-- ==== extension ================== --> <target name="extension_task" /> </project>
|