Skip to content

Compiler ~ Ant Task

Frank Wienberg edited this page Mar 14, 2014 · 1 revision

Ant Task

The preferred way to use Jangaroo is to install Maven and use a pom.xml, as described in the tutorial. This is how all example applications on github are built. The advantage is that all needed Jangaroo tools and libraries are automatically downloaded and used via Maven. Updating tools and libraries is just a matter of changing the corresponding version numbers in the POM.

For those who prefer Ant, we provide an Ant task that invokes the Jangaroo compiler. Note that this Ant task only compiles, and does not take care of many other things the Maven build process does, like compiling in both debug and non-debug mode in parallel or concatenating a joo/jangaroo-application.js file. If you want these features without Maven, you have to simulate them using standard Ant tasks like <unzip>, <copy> and <concat>.

For downloading the required JARs, please follows the instructions on the Jangaroo Tools Wiki page "Stand Alone Compiler".

You can then add a <jooc> task to the Ant build system by means of the following Ant declaration:

<taskdef name="jooc"
         classname="net.jangaroo.jooc.ant.JoocTask">
  <classpath>
    <fileset dir="${jangaroo.tools.lib}">
      <include name="jangaroo-compiler-*.jar"/>
    </fileset>
  </classpath>
</taskdef>

Set the build variable jangaroo.tools.lib to the directory that contains the Jangaroo compiler jars. Afterwards, the compiler may be invoked as follows:

<jooc destdir="${jooc.output}"
      failonerror="true"
      debug="${jooc.debug}"
      verbose="true"
      enableassertions="true"
      sourcepath="${jooc.source}" 
      classpath="${jangaroo-runtime.jar}"
      apidestdir="${jooc.output}/META-INF/joo-api">
  <include name="**/*.as"/>
  <src path="${jooc.source}"/>
</jooc>

Here the build variable jooc.output refers to the target directory, the variable jooc.debug must be to true or false, and the variable jooc.source points to the source directory for Jangaroo sources. The variable jangaroo-runtime.jar denotes the full path to the Jangaroo runtime JAR file.

Possible attributes of the <jooc/> task are:

Attribute Description
destdir destination directory
srcdir source directory
debug true, if you want the compiler to include debug output; false otherwise
debugLevel debug output modes; possible modes are source, lines, none
failonerror if a failing compilation should stop the build process
verbose true, if the compiler should print verbose log messages about the compilation; false otherwise
sourcepath a list of directories which are root directories of Jangaroo sources, separated by the platform specific path separator (available in the Ant variable ${path.separator})
classpath a list of directories or module artifacts (jars) which contain API stubs or the full sources of Jangaroo modules on which the given sources depend on, separated by the platform specific path separator character (available in the Ant variable ${path.separator})
apidestdir destination directory where to generate ActionScript API stubs
enableassertions generate runtime checks for assert statements
autoSemicolon Configures automatic semicolon insertion according to ECMA-262. Possible values are: warn (default) - issue a compiler warning if a line terminator is the cause for semicolon insertion. This might change the meaning of the program in unexpected ways. error - treat this as an error (some kind of strict mode, recommended setting). quirks - silently insert semicolons as JavaScript interpretes and Flex mxmlc do.

The <jooc> task forms an implicit <FileSet> element, so that nested <include> or <exclude> elements may be used to limit the set of files to be processed, as may other appropriate elements and attributes.

If no output directory is specified, output files are written to the directory in which the corresponding input files are placed.

If the debug attribute is not specified or has the value false, use the mode lines. If the attribute debug is specified with a value of true, use the mode that is specified through the option debugLevel or source, if the attribute debugLevel is not present. Mode source generates output that includes all comments, preserves line breaks and white space, and generates readable names for anonymous inner functions. Mode lines only preserves line breaks and white space. Mode none shortens the generated output as far as possible without renaming variables and functions.

Clone this wiki locally