ant build.xml学习

<!---
1.定义全局变量
2.初始化,主要是建立目录
3.编译
4.打包为jar
5.建立API documentation
6.生成distribution产品(发布版本)
-->
<?xml version="1.0" encoding="GB2312"?>
<project default="dist" basedir=".">
<!--主要的系统环境属性-->
<property environment="env"/><!--取windows,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)2004sztelecom lxt008. 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-->
<!--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"/>
<path id="classpath">
<pathelement location="${build.classes}"/>
<pathelement path="${java.home}/lib/tools.jar"/>
</path>
<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>
<target name="build" depends="init">
<javac srcdir="${src.main}" destdir="${build.classes}">
<classpath tefid="classpath"/>
</javac>
</target>
<target name="jars" depends="build">
<jar basedir="${build.classes}" jarfile="${build.lib}/${app.jar}"/>
</target>

<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}"
               defaulttexcludes="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 dp:"/>
    </javadoc>
</target>

<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>
</project>

你可能感兴趣的:(windows,xml,ant,unix)