Development:Writing an Ant task

From Tom

Jump to: navigation, search
Dev : Developping

Writing JUnit tests  > Writing an Ant task  > Creating a new plugin  > Messages and exceptions : Using the logger  > PIL language  > Description of ADT  > Description of external libraries  > New parser's architecture

Ant

The principal way to build Tom and Gom is through the use of apache ant buildfiles. Those buildfiles automate common build and test actions on the Tom project, such as building, running test, building examples or performing bootstrap. The particularities of those buildfiles and the declared targets are to be documented and discussed here.

A build.xml is composed of blocks which define the targets. In each block, it is possible to define dependencies, directories to create, commands to launch, files to delete, ... A build.xml file can be very simple and short, but it useful to write at least a build and a clean target when creating such a file for an example or application. A skeleton of build.xml file can be found below, but for more complex project or application, it will be necessary to add targets. For more information, see build.xml files in jtom/, jtom/applications/ and jtom/examples.

An example of build.xml file

Here is an example of a build.xml file which can be used as a template :

<?xml version="1.0" encoding="UTF-8"?>
 
<project default="javac" basedir=".">
 
  <property environment="env"/>
  <property name="tom.home"      location="../../src/dist"/>
  <property name="example.dir"   location="."/>
  <property name="example.src"   location="${example.dir}/src"/>
  <property name="example.gen"   location="${example.dir}/gen"/>
  <property name="example.build" location="${example.dir}/build"/>
 
  <import file="${tom.home}/lib/tom-common.xml"/>
 
  <target name="init" depends="tom.init">
    <mkdir dir="${example.build}"/>
    <mkdir dir="${example.gen}"/>
  </target>
 
  <target name="tom" depends="gom">
    <tom.preset srcdir="${example.src}"
                destdir="${example.gen}"
                options="-I ${example.gen}">
      <include name="**/*.t"/>
      <exclude name="**/*.g.t"/>
    </tom.preset>
  </target>
 
  <target name="gom" depends="init">
    <gom.preset srcdir="${example.src}"
                destdir="${example.gen}">
      <include name="**/*.gom"/>
    </gom.preset>
  </target>
 
  <target name="javac" depends="tom">
    <javac.preset destdir="${example.build}" >
      <src path="${example.gen}"/>
      <src path="${example.src}"/>
      <include name="**/*.java"/>
    </javac.preset>
  </target>
 
  <target name="clean">
    <delete dir="${example.gen}"/>
    <delete dir="${example.build}"/>
  </target>
 
</project>

Resources

Developping

Writing JUnit tests  > Writing an Ant task  > Creating a new plugin  > Messages and exceptions : Using the logger  > PIL language  > Description of ADT  > Description of external libraries  > New parser's architecture

Development corner
Developping Tom Compiler :: Creating a Tom release
Personal tools
Create a book