Ant - Skip Header




The com.Ostermiller.Syntax package comes with an Ant task to automate the creation of colored html documents during your Java software build process. To use the ant task, simply place syntax.jar in Ant's lib directory.


Attribute Description Required
srcdir Location of the files to color. Defaults to the project's basedir. No
destdir Location to store the colored files. Defaults to the srcdir. No
css URL of the cascading style sheet to which generated files should be linked. If this option is not specified, the pages are linked to a default "syntax.css". If this file is not present, the pages will not appear to have any color. Example style sheet No
includes Comma separated list of file globs to accept. If not specified, all files in all subdirectories are colored. No
excludes Comma separated list of file globs to reject that would otherwise be accepted. If not specified, no files are excluded. No
mime Mime-type of the files to color. If not specified, the mime-type is guessed from the file extension. No
lexer Class name to use for the syntax highlighting lexer. If none is specified, it is guessed from the mime-type and file extension. No
title Title to use for the colored html page. If none is specified, "HTML of filename" is used. No
template URL of the BTE template file to use. The URL may be relative to the projects basedir. If none is specified, the colored html pages have a simple default look and feel. For this option to work, the BTE libraries must be installed. For a template example, see the template for the default look and feel. No

Parameters specified as nested elements

parameter type="ignore"

CSS class name of token to ignore. This is desirable to reduce the size of the generated html files. It is almost always good idea to ignore whitespace.

Attribute Description Required
name The name of the style to ignore. Yes

parameter type="translate"

CSS class name to translate to a new name. Names can be translated for compatibility purposes. They can also be translated to make files smaller. For example, it is possible to have a "k" instead of "keyword".

Attribute Description Required
name The original name of the style to translate. Yes
value The new name of the style. Yes


Create syntax highlighting for java source files:
<taskdef name="syntax" classname="com.Ostermiller.Syntax.ToHTMLAntTask" />
<target name="highlight">
  <syntax includes="*.java" />
Create syntax highlighting for all files except the generated highlighted files:
<taskdef name="syntax" classname="com.Ostermiller.Syntax.ToHTMLAntTask" />
<target name="highlight">
  <syntax excludes="*.*.html" />
More complete example of highlighting java source files, with some recommended options:
<taskdef name="syntax" classname="com.Ostermiller.Syntax.ToHTMLAntTask" />
<target name="highlight">
  <mkdir dir="colored" />
  <syntax destdir="colored" includes="*.java" css="mysyntax.css">
	<parameter type="ignore" name="whitespace" />
  <copy file="mysyntax.css" todir="colored" />