Ant Tasks

On this page we explain how to work with ABS models using Ant. The tasks of this page are all included in the file build.xml template file.


Folder Layout

The following targets are all based on the following project layout:

+ Project
  +- src/abs/     -- contains all .abs files of the ABS model
     +- test.abs  -- an abs file with a module <<<Test>>> and a main block
  +- lib/         -- contains necessary jar files
  +- target/java  -- will contain generated Java code and is created

Test File

The file test.abs has the following content:

module Test;

// the main block
  assert False;

Ant Properties

We thus use the following Ant properties. The only property which has to be adapted for your project is the abs.mainmodule property, which specifies which main block is executed when executing the ABS system.

  <property name="lib" location="lib" />
  <property name="src" location="src" />
  <property name="target" location="target" />
  <property name="src.abs" location="${src}/abs" />
  <property name="" location="${target}/java/src" />
  <property name="" location="${target}/java/bin" />

  <property name="lib.abs" location="${lib}/absfrontend.jar" />

  <!-- change this to the name of the module that contains the main block -->
  <property name="abs.mainmodule" value="Test" />


We define the build.abs.classpath to hold the absfrontend.jar

ABS model files

<path id="build.abs.classpath">
   <pathelement location="${lib.abs}"/>

The fileset src.abs.files and the path absfileargs hold all ABS files of the ABS model.

<fileset dir="${src.abs}" id="src.abs.files">
   <include name="**/*.abs" />
<pathconvert property="src.abs.fileargs" refid="src.abs.files" pathsep=" " />


The target prepare creates the necessary target folders. It depends on the target lib.abs.getjar explained below.

<target name="prepare" depends="lib.abs.getjar">
  <mkdir dir="${}" />
  <mkdir dir="${}" />


A corresponding clean target deletes all generated files

<target name="clean" description="Removes all generated files">
  <delete failonerror="false" includeemptydirs="true">
    <fileset dir="${target}"/>

Download the newest ABS JAR

In order to automatically download the newest absfrontend.jar you can use the following Ant target:

<target name="lib.abs.getjar">
  <mkdir dir="${lib}" />
  <get src=""
       dest="${lib}" usetimestamp="true" verbose="true" />

This target will download the absfrontend.jar and put it into the lib folder. Before downloading it will check if the newest version (based on a timestamp) is already existing and only download the jar file if it is newer than the existing one.

Type-Check the ABS model

To type check an ABS model use the following target:

<target name="abs.typecheck" depends="prepare">
  <java classname="abs.frontend.parser.Main"
     fork="true" failonerror="true"
     <arg line="${src.abs.fileargs}"/>

Generate, Compile, and run Java code

Generate Java code

To generate Java code from the ABS model use the following target:

<target name="" 
  description="Generates Java code" depends="clean,prepare">
  <echo>FILES: ${src.abs.fileargs}</echo>
  <java classname="" 
    fork="true" failonerror="true" classpathref="build.abs.classpath">
    <arg line="${src.abs.fileargs}"/>
    <arg value="-sourceonly" />
    <arg value="-d" />
    <arg value="${}" />

Compile Java code

To compile the generated Java code use the following target:

<target name="" depends="">
  <javac classpathref="build.abs.classpath" 

Run Java code

The following target runs the generated Java code

  <target name="" depends="">
    <java classname="${abs.mainmodule}.Main">
	 <path refid="build.abs.classpath" />
	 <pathelement path="${}" />