一个 ANT 工程文件的示例
类别: JSP教程
下面是一个 ANT 工程文件的示例 build.xml,供大家参考。更多的使用方法请参阅 ANT 自带的文档。
<?xml version="1.0"?>
<project default="dist" basedir=".">
<property name="name" value="bbs"/>
<property name="version" value="1"/>
<property name="year" value="2002"/>
<property name="language" value="en"/>
<!--
Give user a chance to override without editing this file
(and without typing -D each time he compiles it)
-->
<property file=".ant.properties"/>
<property file="${user.home}/.ant.properties"/>
<!--
There should be no need to override default compiler but need to change
javac task to run without this
-->
<property name="build.compiler" value="jikes"/>
<!--
<property name="build.compiler" value="classic"/>
-->
<!--
these are here only for those who use jikes compiler. For other
developers this part makes no difference.
-->
<property name="build.compiler.emacs" value="on"/>
<property name="build.compiler.pedantic" value="true"/>
<property name="build.compiler.depend" value="true"/>
<property name="build.compiler.fulldepend" value="true"/>
<property name="debug" value="on"/>
<property name="optimize" value="off"/>
<property name="deprecation" value="off"/>
<!--
===================================================================
Set the properties for intermediate directory
===================================================================
-->
<property name="build.dir" value="build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.webapps" value="${build.dir}/webapps"/>
<property name="dist.dir" value="dist"/>
<property name="dist.classes" value="${dist.dir}/WEB-INF/classes"/>
<property name="src.dir" value="src"/>
<property name="classes.dir" value="${src.dir}/classes"/>
<property name="webapps.dir" value="${src.dir}/webapps"/>
<path id="project.class.path">
<pathelement path="${java.class.path}" />
<pathelement path="${build.classes}" />
</path>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage">
<echo message=""/>
<echo message=""/>
<echo message="xiaoyoung BBS Build file"/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=" available targets are:"/>
<echo message=""/>
<echo message=" compile --> compiles the source code"/>
<echo message=" dist --> generates the distribution, packed"/>
<echo message=" clean --> cleans up the directory"/>
<echo message=""/>
<echo message=" See the comments inside the build.xml file for more details."/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=""/>
</target>
<!-- =================================================================== -->
<!-- Building
<!-- =================================================================== -->
<target name="prepare">
<mkdir dir="${build.classes}"/>
</target>
<target name="compile" depends="prepare">
<javac destdir="${build.classes}"
optimize="${optimize}"
deprecation="${deprecation}">
<classpath refid="project.class.path" />
<src path="${classes.dir}" />
</javac>
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist.dir}" />
<copy todir="${dist.dir}" >
<fileset dir="${webapps.dir}" />
</copy>
<mkdir dir="${dist.classes}" />
<copy todir="${dist.classes}" >
<fileset dir="${build.classes}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- Cleans everything -->
<!-- =================================================================== -->
<target name="setup-properties" >
<tstamp/>
<property name="dist.dir" value="dist"/>
</target>
<target name="clean" depends="setup-properties">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete verbose="true">
<fileset dir="." includes="**/*~" defaultexcludes="no"/>
<fileset dir="." includes="**/*.bak"/>
</delete>
</target>
</project>
<?xml version="1.0"?>
<project default="dist" basedir=".">
<property name="name" value="bbs"/>
<property name="version" value="1"/>
<property name="year" value="2002"/>
<property name="language" value="en"/>
<!--
Give user a chance to override without editing this file
(and without typing -D each time he compiles it)
-->
<property file=".ant.properties"/>
<property file="${user.home}/.ant.properties"/>
<!--
There should be no need to override default compiler but need to change
javac task to run without this
-->
<property name="build.compiler" value="jikes"/>
<!--
<property name="build.compiler" value="classic"/>
-->
<!--
these are here only for those who use jikes compiler. For other
developers this part makes no difference.
-->
<property name="build.compiler.emacs" value="on"/>
<property name="build.compiler.pedantic" value="true"/>
<property name="build.compiler.depend" value="true"/>
<property name="build.compiler.fulldepend" value="true"/>
<property name="debug" value="on"/>
<property name="optimize" value="off"/>
<property name="deprecation" value="off"/>
<!--
===================================================================
Set the properties for intermediate directory
===================================================================
-->
<property name="build.dir" value="build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.webapps" value="${build.dir}/webapps"/>
<property name="dist.dir" value="dist"/>
<property name="dist.classes" value="${dist.dir}/WEB-INF/classes"/>
<property name="src.dir" value="src"/>
<property name="classes.dir" value="${src.dir}/classes"/>
<property name="webapps.dir" value="${src.dir}/webapps"/>
<path id="project.class.path">
<pathelement path="${java.class.path}" />
<pathelement path="${build.classes}" />
</path>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage">
<echo message=""/>
<echo message=""/>
<echo message="xiaoyoung BBS Build file"/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=" available targets are:"/>
<echo message=""/>
<echo message=" compile --> compiles the source code"/>
<echo message=" dist --> generates the distribution, packed"/>
<echo message=" clean --> cleans up the directory"/>
<echo message=""/>
<echo message=" See the comments inside the build.xml file for more details."/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=""/>
</target>
<!-- =================================================================== -->
<!-- Building
<!-- =================================================================== -->
<target name="prepare">
<mkdir dir="${build.classes}"/>
</target>
<target name="compile" depends="prepare">
<javac destdir="${build.classes}"
optimize="${optimize}"
deprecation="${deprecation}">
<classpath refid="project.class.path" />
<src path="${classes.dir}" />
</javac>
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist.dir}" />
<copy todir="${dist.dir}" >
<fileset dir="${webapps.dir}" />
</copy>
<mkdir dir="${dist.classes}" />
<copy todir="${dist.classes}" >
<fileset dir="${build.classes}" />
</copy>
</target>
<!-- =================================================================== -->
<!-- Cleans everything -->
<!-- =================================================================== -->
<target name="setup-properties" >
<tstamp/>
<property name="dist.dir" value="dist"/>
</target>
<target name="clean" depends="setup-properties">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete verbose="true">
<fileset dir="." includes="**/*~" defaultexcludes="no"/>
<fileset dir="." includes="**/*.bak"/>
</delete>
</target>
</project>
- 上一篇: 制作可以执行的 JAR 文件包及 JAR 命令详解
- 下一篇: JVM之CLASS文件结构
-= 资 源 教 程 =-
文 章 搜 索