Skip to main content
Jump to: navigation, search

Difference between revisions of "OTHowtos/Compiling With Ant"

(Compiling OT/J source using ANT)
 
(4 intermediate revisions by 2 users not shown)
Line 5: Line 5:
  
 
Should you need to compile an [[OTJ|OT/J]] program outside the [[Object Teams Development Tooling|OTDT]], the following steps should enable you to use ANT for this task:  
 
Should you need to compile an [[OTJ|OT/J]] program outside the [[Object Teams Development Tooling|OTDT]], the following steps should enable you to use ANT for this task:  
* download [http://www.eclipse.org/downloads/download.php?file=/objectteams/ecotj/ecotj-R-0.7.1-201009231848.jar ecotj.jar]
+
* [https://www.eclipse.org/objectteams/download.php download] '''ecotj.jar''' — ''please find the desired version in the column "Command Line Compiler"''
: ''you'll always find the latest version [http://www.eclipse.org/objectteams/download.php here] in the column "Command Line Compiler"''
+
 
* add it to your ANT runtime classpath (either place it in your ant_lib directory or provide the path by a <code>-lib</code> command line option to ant).  
 
* add it to your ANT runtime classpath (either place it in your ant_lib directory or provide the path by a <code>-lib</code> command line option to ant).  
* in your <code>build.xml</code> set the property <code>build.compiler</code> to use the OTDT compiler in <code><nowiki><javac></nowiki></code> tasks, like that: <pre><property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" /></pre>
+
* in your <code>build.xml</code> set the property <code>build.compiler</code> to use the OTDT compiler in <code><nowiki><javac></nowiki></code> tasks, like that:  
 +
<source lang="xml"><property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" /></source>
 
*just use <code><nowiki><javac></nowiki></code> tasks in your <code>build.xml</code> to compile the code.
 
*just use <code><nowiki><javac></nowiki></code> tasks in your <code>build.xml</code> to compile the code.
  
Line 20: Line 20:
 
         <!-- regular use of javac task (source="1.5" or greater is actually required): -->
 
         <!-- regular use of javac task (source="1.5" or greater is actually required): -->
 
         <javac srcdir="src" destdir="bin"  
 
         <javac srcdir="src" destdir="bin"  
               classpath="${otre.path}:${user.classpath}"  
+
               classpath="${otre.jar}:${user.classpath}"  
 
               source="1.5" target="1.5"/>
 
               source="1.5" target="1.5"/>
 
     </target>
 
     </target>
Line 27: Line 27:
  
 
This script is invoked with  
 
This script is invoked with  
<pre>$ ant -lib ecj-export -Dotre.path=lib/otre.jar</pre>
+
<pre>$ ant -lib ecj-dir -Dotre.jar=otre-jar</pre>
  
 
You'll have to substitute the following paths:  
 
You'll have to substitute the following paths:  
* ecj-export: directory containing the appropriate <code>ecotj-''version''.jar</code>
+
* ecj-dir: directory containing the appropriate <code>ecotj-''version''.jar</code>
* lib: path to the Object Teams Runtime Environment (OTRE), which can be found in <code>eclipse/plugins/org.objectteams.otdt_''version''/lib</code>.<br/> This path can of course also be defined using a property definition within the build script.
+
* otre-jar: path to the Object Teams Runtime Environment (OTRE), pointing to <code>eclipse/plugins/org.eclipse.objectteams.runtime_''version''.jar</code>.<br/> This path can of course also be defined using a property definition within the build script.
  
 
[[Category:Object Teams|Compiling with Ant]]
 
[[Category:Object Teams|Compiling with Ant]]

Latest revision as of 08:13, 26 June 2015

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 ecotj.jarplease find the desired version in the column "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.jar}:${user.classpath}" 
               source="1.5" target="1.5"/>
    </target>
</project>

This script is invoked with

$ ant -lib ecj-dir -Dotre.jar=otre-jar

You'll have to substitute the following paths:

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

Back to the top