JSE

Description

Invokes the Java Syntactic Extender (JSE) java macro preprocessor. It expands macro definitions and calls defined in jse files into java source, which may then be compiled to class files by the usual compiler tasks.

Installation

You must have a working Ant installation. Unzip the JSE distribution in a directory on your machine. Then, in the base JSE directory, issue the following command:
ant install
This command will copy jse.jar to Ant's lib directory.

Use

To use the jse task, set the jsedir attribute to the base directory that the source jse files are in. When the jse source files are part of a package, the directory structure of the source tree should follow the package hierarchy.

Note also that you will need to add a <taskdef> element to your build file to register the jse task. See the example below.

Typically macro definitions should be expanded then compiled first, then macro calls expanded then compiled.

Parameters

Attribute Description Required
jsedir Directory containing the source jse files. Yes
javadir Directory to store the generated java files. If not specified this defaults to jsedir. No
classpath The classpath to use for referencing macro definitions. No
lineup Maintain source line positions. This is a boolean option, whose default is true. If not set then the source is pretty-printed. No
recursive Expand macros recursively. This is a boolean option, whose default is true. No
verbose Sets verbose tracing for debugging purposes. This is a boolean option, whose default is false. No

Parameters specified as nested elements

This task is a directory based task, like javac, so the jse files to be processed are located as java files are by javac. That is, elements such as includes and excludes can be used directly inside the task declaration.

Example

    <taskdef name="jse" classname="net.sf.jse.ant.JseAntTask"/>
    
    <jse jsedir="jse" javadir="src" lineup="false">
      <include name="**/*SExpander.jse"/>
    </jse>
    <javac srcdir="src" destdir="classes" />
This invokes JSE on all files which end in the pattern SExpander.jse (the macro definitions) under the jse directory and puts the expanded java source into the src directory. The java source for the macro definitions is then compiled using the javac core task.
    <jse jsedir="jse" javadir="src" classpath="classes">
      <exclude name="**/*SExpander.jse"/>
    </jse>
    <javac srcdir="src" destdir="classes" />
This invokes JSE on all files which don't end in the pattern SExpander.jse (the macro calls) under the jse directory and puts the expanded java source into the src directory. The classpath is set so that the macro definitions which were previously expanded and compiled can be referenced. The java source for the remaining classes (the macro calls) is then compiled.