Installation: 
1. Set the ANT_HOME environment variable to point to this location. 
2. Set the JAVA_HOME environment variable to point to the JDK location. 
3. Add ANT_HOME/bin to your system's PATH environment variable. 
Build file : 
1.     ${build.dir} means referenced a var :build.dir 
  
2.     specify diretory : 
<property name="src.dir" value="src"/> 
  <!-- Temporary build directories --> 
  <property name="build.dir" value="build"/> 
  
3.     make dir on specified diretory : 
  <target name="prepare"> 
    <mkdir dir="${build.lib}"/> 
  </target> 
  
4.     clean dir 
  <target name="clean" description="Remove all generated files."> 
    <delete dir="${build.dir}"/> 
  </target> 
  
5.     compile java files 
  <target name="compile" depends="prepare" 
          description="Compiles all source code."> 
<javac srcdir="${src.dir}"  
destdir="${build.classes}"/> 
  </target> 
  
6.     jar java files 
  <target name="jar" depends="compile" 
          description="Generates oreilly.jar in the 'dist' directory."> 
    <!-- Exclude unit tests from the final JAR file --> 
    <jar jarfile="${build.lib}/oreilly.jar"  
         basedir="${build.classes}" 
         excludes="**/*Test.class"/> 
  </target> 
  
7.     target can be invoked single : eg. 
command line : ant jar 
  
8.     specify classpath and compile : 
<path id="mypath"> 
<pathelement location="${java.home}/jre/lib/rt.jar"/> 
</path> 
<target name="all"> 
<javac srcdir="."> 
<classpath refid="mypath"/> 
</javac> 
</target> 
or  
<path id="classpath"> 
<fileset dir="${lib.dir}"> 
<include name="**/*.jar"/> 
</fileset> 
</path> 
  
9.     copy files 
<copy todir="${weblogic.dir}/${weblogic.server.home}/public_html/jsp"> 
<fileset dir="${src.www.dir}/jsp"/> 
</copy> 
  
10.Javadoc 
<target name = “javadoc” depends=”compile,jar”> 
    <mkdir dir = “${doc.dir}/api”/> 
    <javadoc packagenames = “ myproj.*” 
        sourchpath = “${src.dir}” 
        destdir = “${doc.dir}/api” 
        author = “true” 
        version = “true” 
       use = “true”> 
    <classpath refid = “classpath”/> 
    </javadoc> 
</target> 
  
all in a build.xml file: 
  
<?xml version="1.0"?> 
  
<!-- build.xml - a simple Ant buildfile --> 
<project name="Simple Buildfile" default="compile" basedir="."> 
  
  <!-- The directory containing source code --> 
  <property name="src.dir" value="src"/> 
  
  <!-- Temporary build directories --> 
  <property name="build.dir" value="build"/> 
  <property name="build.classes" value="${build.dir}/classes"/> 
  <property name="build.lib" value="${build.dir}/lib"/> 
  
  <!-- Target to create the build directories prior to the --> 
  <!-- compile target. --> 
  <target name="prepare"> 
    <mkdir dir="${build.dir}"/> 
    <mkdir dir="${build.classes}"/> 
    <mkdir dir="${build.lib}"/> 
  </target> 
  
  <target name="clean" description="Remove all generated files."> 
    <delete dir="${build.dir}"/> 
  </target> 
  
  <target name="compile" depends="prepare" 
          description="Compiles all source code."> 
    <javac srcdir="${src.dir}" destdir="${build.classes}"/> 
  </target> 
  
  <target name="jar" depends="compile" 
          description="Generates oreilly.jar in the 'dist' directory."> 
    <!-- Exclude unit tests from the final JAR file --> 
    <jar jarfile="${build.lib}/oreilly.jar"  
         basedir="${build.classes}" 
         excludes="**/*Test.class"/> 
  </target> 
  
  <target name="all" depends="clean,jar" 
          description="Cleans, compiles, then builds the JAR file."/> 
  
</project> 
   
 
  |