Java2Html - Ant Task

 
 

Ant Task

This task converts Java source files to HTML, TeX or other supported formats using the Java2Html converter.

Note: This task depends on external libraries not included in the Ant distribution. You must have java2html.jar on the classpath or in Ants lib folder at ANT_HOME/lib.

Parameters

Attribute Description Required
srcdir Source folder containing files (or subfolders with files) for conversion. No, default is the project directory
destdir Destination folder for output of the converted files. Yes
includes File mask for input files, e.g. **/*.java No
outputFormat File format for conversion output. Valid values are all names of currently implemented converters, e.g.:
  • html for XHTML 1.0 Transitional (inlined fonts)
  • xhtml11 for XHTML 1.1 (with stylesheet)
  • xhtml for XHTML 1.0 transitional (with stylesheet)
  • tex for TeX
  • rtf for RTF
  • xml for XML
No, default is html
tabs Width in spaces for a tab character. No, default is 2
style Sets the table name for the output style. Valid values are:
  • eclipse For a style similar to the one in the Eclipse IDE
  • kawa For a style similar to the one in the Kawa IDE
  • monochrome For a monochrome style w/o colors
No, default is eclipse
showLineNumbers Show line numbers in conversion output: true or false No, default is true
showFileName Show the file name in conversion output: true or false No, default is false
showDefaultTitle Sets the title of generated html pages (if any) to the relative name of the source file, e.g. de/java2html/Java2Html.java: true or false No, default is false
showTableBorder Show a border around the conversion output: true or false No, default is false
includeDocumentHeader Add a document header at the beginning of the output file: true or false No, default is true
includeDocumentFooter Add a document footer at the end of the output file: true or false No, default is true
addLineAnchors Add html-anchors to each line for html output: true or false No, default is false
lineAnchorPrefix String that will be added as prefix for the line anchors for html output. No
horizontalAlignment Horizontal alignment of the output: left, center or right No, default is left
useShortFileName Use short (ClassName.html) or long (ClassName.java.html) filenames for output: true or false No, default is false
overwrite Overwrite existing files even if the destination files are newer: true or false No, default is false

Note that some of the options are not supported by all output formats.

Most default options are derived from a java2html.properties file on the classpath if there exists any.

Example

<taskdef name="java2html"
    classname="de.java2html.anttasks.Java2HtmlTask"
    classpath="${build.dir}"
/>
<java2html
       srcdir="${src.dir}"
       destdir="${scratch.dir}"
       includes="**/*.java"
       style="eclipse"
       showLineNumbers="true"
       showFileName="true"
       showTableBorder="true"
/>

Converts all *.java files from the ${src.dir} and its subfolders to ${scratch.dir} using the eclipse output style. Line numbers, the filename and a table border are added to the result.

Valid XHTML 1.0!
© Markus Gebhard (markus@jave.de), 2000 - 2008
last modified: May 4, 2008