Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

OTHowtos/Compiling With Ant

Compiling OT/J source using ANT

Thanks to Carsten Pfeiffer for these instructions. Cf. also this Eclipse help page (scroll to "Using the ant javac adapter").


Should you need to compile an OT/J program outside the OTDT, the following steps should enable you to use ANT for this task:

  • download http://www.objectteams.org/distrib/otdt/1.3/ecotj-1.3.0.jar (you'll always find the latest version at http://www.objectteams.org/distrib under the heading "OT/J command line compiler").
  • add it to your ANT runtime classpath (either place it in your ant_lib directory or provide the path by a -lib command line option to ant).
  • in your build.xml set the property build.compiler to use the OTDT compiler in <javac> tasks, like that:
    <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
  • just use <javac> tasks in your build.xml to compile the code.

Here is a build.xml that can be used for compiling the sample OTSample-Flightbonus, provided that subcomponents have already been compiled into booking.jar and bonussystem.jar:

<?xml version="1.0" encoding="UTF-8"?>
<project name="fbapplication" default="all" basedir=".">
    <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
    <!-- adjust this to your project's requirements: -->
    <property name="user.classpath" value="booking.jar:bonussystem.jar" />
    <target name="compile">
        <!-- regular use of javac task (source="1.5" or greater is actually required): -->
        <javac srcdir="src" destdir="bin" 
               classpath="${otre.path}:${user.classpath}" 
               source="1.5" target="1.5"/>
    </target>
</project>

This script is invoked with

$ ant -lib ecj-export -Dotre.path=lib/otre.jar

You'll have to substitute the following paths:

  • ecj-export: directory containing the appropriate ecotj-version.jar
  • lib: path to the Object Teams Runtime Environment (OTRE), which can be found in eclipse/plugins/org.objectteams.otdt_version/lib.
    This path can of course also be defined using a property definition within the build script.

Back to the top