Sample ANT Build Script

Although the sample ANT build script is created by iWay, it may not apply to your own build environment as is. You will need to modify the build script for directory paths, .jar file locations, project names, and so on.

<?xml version="1.0" ?>
<!-- ================================================= -->
<!-- Sample build script, set myproject to the value in engine -->
<!-- USE THIS ANT SCRIPT AS A STARTING POINT. -->
<!-- ================================================= -->
<project name="myproject" default="extension" basedir=".">
  <!-- ======================================= -->
  <!-- Macros used in the build -->
  <!-- ======================================= -->
  <property environment="env"/>
  <property name="build.sysclasspath" value="ignore"/>
  <property name="build.dir" value="classes" />
  <!-- out.dir is where I want the result -->
  <property name="out.dir" value="." />
  <!-- mycompany is my id; used to locate the register class -->
  <property name="mycompany" value="companyidentifier"/>
  <!-- engine is the name of my project extension; used to locate the
   register class and name the jar-->
  <property name="engine" value="myproject" /> 
  
  <!-- ============================================== -->
  <!-- The path below is becomes the compile classpath -->
  <!-- This MUST appear below the macro definitions -->
  <!-- ============================================== -->
  <path id="project.classpath">
     <fileset dir="${out.dir}">
        <include name="**/*.jar"/>
        <include name="**/*.zip"/>
     </fileset>
  </path>
  <!-- ================================= -->
  <!-- compile -->
  <!-- ================================= -->
  <target name="compile">
  
   <mkdir dir="${build.dir}"/>
   <javac
    classpathref="project.classpath" 
    srcdir="${basedir}/src" 
    destdir="${build.dir}" 
    
    failonerror="${javac.failonerror}"
    debug="on" 
    optimize="on"
    fork="yes"
    memorymaximumsize="256m" 
    deprecation="off" 
   >
    <include name="**/*.java"/>
   </javac>
  </target>
  <!-- jar it up; note where the register class will be found -->
  <target name="jar" depends="compile" >
    <mkdir dir="${build.dir}/META-INF"/>
    <tstamp/>
    <manifest file="${build.dir}/META-INF/MANIFEST.MF">
      <attribute name="Built-On" value="mycomputer ${TODAY} ${TSTAMP}"/>
      <attribute name="Version"  value="1"/> 
      <attribute name="Build"    value="1"/> 
      <attribute name="Implementation-Version"   value="7.0.5"/>
      <section name="IXTEComponent">
       <attribute name="Register	
       "value="com.${mycompany}.${engine}.Register"/>
      </section>
    </manifest>
    
    <echo message="Building ${engine}.jar"/>
    <echo message="Building directory ${build.dir}"/>
   <jar
    jarfile="${out.dir}/${engine}.jar"
     basedir="${build.dir}"
     manifest="${build.dir}/META-INF/MANIFEST.MF"
   />
  </target>
  <!-- =============================================================-->
  <!-- clean -->
  <!--==============================================================-->
  <target name="clean">
    <echo>Clean ${ant.project.name}</echo>
    <delete file="${out.dir}/${engine}.jar"/>
    <delete dir="${build.dir}"/>
  </target>
  <!-- =============================================================-->
  <!-- ***KICKER*** -->
  <!--==============================================================-->
  <target name="myproject" depends="jar" description="BUILD"/>
</project>

iWay Software