<?xml version="1.0" encoding="GB2312" ?>
<!--
文档结构为:
<project>
<property/> 全局变量的定义
<property/>...
<target name="1"> 任务组(tasks)
<javac></javac> 一项javac任务
...
<oneTask></ontTask> 一项其它任务
</target>
<target name="2">
<javac></javac>
...
<oneTask></ontTask>
</target>
</project>
project代表一个项目,
default:运行到名称为"dist"的target(任务组)
basedir:基准路径。
-->
<project default="dist" basedir=".">
<!--
===================================================================
定义属性(property tasks)
最好把用到的路径呀,名称呀都在这里定义成全局变量
例:定义
<property name="a" value="hello"/>
以后就可以这样用它:
<property name="b" value="${a}/b"/>
现在:b=="hello/b"
===================================================================
-->
<!--主要的系统环境属性-->
<property environment="env"/><!--取window,unix...的环境变量-->
<property name="java.home" value="${env.JAVA_HOME}"/>
<property name="ant.home" value="${env.ANT_HOME}"/>
<!--主要的app环境属性-->
<property name="app.name" value="hello-ant"/>
<property name="app.jar" value="${app.name}.jar"/>
<property name="app.copyright" value=" Copyright (c) 2002 The Neusoft Software Foundation. All rights reserved."/>
<!--app中src的属性-->
<property name="src.dir" value="src" />
<property name="src.main" value="${src.dir}/main"/>
<property name="src.script" value="${src.dir}/script"/>
<!--app用到的lib-->
<property name="lib.dir" value="lib"/>
<!--app的build目录中-->
<property name="build.dir" value="build" />
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.docs" value="${build.dir}/docs"/>
<property name="build.docs.api" value="${build.docs}/api"/>
<property name="build.lib" value="${build.dir}/lib"/>
<!--app的dist (distribution) 目录中-->
<property name="dist.dir" value="dist"/>
<property name="dist.bin" value="${dist.dir}/bin"/>
<property name="dist.docs" value="${dist.dir}/docs"/>
<property name="dist.lib" value="${dist.dir}/lib"/>
<!--app的docs目录中-->
<property name="docs.dir" value="docs"/>
<!--
定义一组路径以后可以通过id重用这组路径 ,例:
<javac srcdir="src/main" destdir="build/classes">
<classpath refid="classpath"/>
</javac>
-->
<path id="classpath">
<!--本项目只有一个java,用不上classpath,这里只是做个例子-->
<pathelement location="${build.classes}"/>
<pathelement path="${java.home}/lib/tools.jar"/>
</path>
<!--
===================================================================
init 准备目录(File Tasks)
主要的目录结构通常是不会变的,一起生成他们
===================================================================
-->
<target name="init">
<!--清除以前目录-->
<delete dir="${build.dir}" failonerror="false" />
<delete dir="${dist.dir}" failonerror="false"/>
<!--准备目录-->
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.docs}"/>
<mkdir dir="${build.docs.api}"/>
<mkdir dir="${build.lib}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.bin}"/>
<mkdir dir="${dist.lib}"/>
</target>
<!--
===================================================================
Build the code (Compile Tasks,File Tasks)
===================================================================
-->
<target name="build" depends="init">
<!--编译-->
<javac srcdir="${src.main}" destdir="${build.classes}">
<classpath refid="classpath"/>
</javac>
</target>
<!--
===================================================================
打包文档(Archive Tasks)
Create the project jars: xxx1.jar and xxx2.jar
===================================================================
-->
<target name="jars" depends="build">
<jar basedir="${build.classes}" jarfile="${build.lib}/${app.jar}"/>
</target>
<!--
===================================================================
Creates the API documentation
===================================================================
-->
<target name="javadocs"
depends="jars"
description="--> creates the API documentation">
<!--copy docs 手册... -->
<copy todir="${build.docs}">
<fileset dir="${docs.dir}"/>
</copy>
<javadoc packagenames="hello.ant.*"
sourcepath="${src.main}"
defaultexcludes="yes"
destdir="${build.docs.api}"
author="true"
version="true"
use="true"
windowtitle="Docs API">
<doctitle><![CDATA[<h1>hello ant Docs API</h1>]]></doctitle>
<bottom><![CDATA[<i>${app.copyright}</i>]]></bottom>
<tag name="todo" scope="all" description="To do:" />
</javadoc>
</target>
<!--
===================================================================
Create the distribution that can run (Archive Tasks)
主要是从各目录中把该copy的copy上
===================================================================
-->
<target name="dist" depends="javadocs">
<!--copy bin 执行文件 -->
<copy todir="${dist.bin}">
<fileset dir="${src.script}/"/>
</copy>
<copy todir="${dist.docs}">
<fileset dir="${build.docs}/"/>
</copy>
<!-- copy lib 文件 -->
<copy todir="${dist.lib}">
<fileset dir="${build.lib}/"/>
</copy>
</target>
<!--
===================================================================
Cleans everything(File Tasks)
例如可以删除build中的文件,留给你发挥吧
===================================================================
-->
</project>