com.lutris.ant.taskdefs
Class Xmlc

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.tools.ant.taskdefs.MatchingTask
                    |
                    +--com.lutris.ant.taskdefs.Xmlc
All Implemented Interfaces:
org.apache.tools.ant.types.selectors.SelectorContainer

public class Xmlc
extends org.apache.tools.ant.taskdefs.MatchingTask

Invoke the XMLC compiler to read markup files and generate Java code for DOM manipulation.
Typically made visible to an Ant build file with the following declaration:

    <taskdef name="xmlc" classname="com.lutris.ant.taskdefs.Xmlc"/>
Parameters

srcdir - The source directory root. Required = Yes.
sourceout - The destination directory for the generated java code. If not specified, then the srcdir is assumed. Required = No.
destdir - The destination directory root. Useful to make XMLC do the compilation and check dependencies. Required = No.
packagedir - Package prefix for generated classes. Expressed as a directory path. If not specified, the relative path from srcdir becomes the package. packagedir can be expressed as a directory path, either '/' or '\' are accepted.
Note: packagedir is used to set the package name of the generated class, and to specify the directory where the file will be generated (relative to sourceout). As such, any directory prefix on a source file is stripped before the packagedir is applied. This means that all files from the source tree will end up in the same directory, which may not be what you intend, if you are using Xmlc to process files in a directory hierarchy. Required = No.
Default value = No blank package
packagename - Set the package prefix for generated classes, while preserving any source file directory paths. This is useful if you want to take source (markup language) files from one tree, but generate the Java code into another tree, preserving relative paths. Required = No.
For example, suppose that you have .html files under a directory called "discRack/resources" and you want to generate Java code under "discRack/src" but have the package name be "a.b" The following task achieves this:
 <xmlc srcdir="discRack/resources"
          	sourceout="discRack/src"
          	packagename="a.b" />
A markup file located at "discRack/resources/c/d/discRack.ml" will be generated to "discRack/src/a/b/c/d/discRackML.java" and will start with a "package a.b.c.d" statement.

markup - The kind of markup language being processed. Choices currently include: The generated class is suffixed with this value. Note that this does not control the the type of markup language, it controls only the filename suffix, the actual markup is controlled through the XMLC -dom option which is accessible through the args attribute or element. Required = No. Default value = HTML

verbose - Displays the XMLC command and all of the arguments Required = No. Default value = false

compile - Have XMLC compile the resulting java files? Note: The default is to not invoke the Java compiler through XMLC, since this is really slow. Any java files created are better handled by the Ant rule. Required = No. Default value = false

keep - Keep the Java files generated by XMLC? To not keep them, you must allow XMLC to compile them first. However, since this is slower, the default is to keep them and let Ant compile the files using a seperate task. Required = No. Default value = true

performExec - XMLC is invoked by performing a Runtime.exec() on the value provided as the argument: e.g. 'performexec="xmlc"' (kept for historical reasons by the author). Required = No. Default value = false

options - File name of XMLC options file. This is searched for in the 'srcdir' then 'sourceout' then relative to the project dir or and an absolute path. The file extension should be .xmlc E.g. options.xmlc. Required = No

<arg> - Nested element representing additional command line arguments to be passed to XMLC. See the XMLC documentation for all the possible commands.
Note: these are applied after the other XMLC arguments derived from the options listed above.

For example, to specify an URL mapping to XMLC:
            <xmlc source="." includes="*.html">
              <arg value="-urlmapping" />
              <arg value="Edit.html" />
              <arg value="To.po" />
            </xmlc>
Caution: Do not be tempted to surround the URL's with single-quotes, as is common when calling XMLC from a shell command line, for example
            <xmlc source="." includes="*.html">
              <arg line="-urlmapping 'Edit.html' 'To.po'" />
            </xmlc>
The single-quotes will be taken as part of the URL to replace, and this is probably not what you intend. Required = No.


Inner Class Summary
static class Xmlc.BooleanAttribute
           
 
Field Summary
protected  java.lang.String classPath
          The classpath for XMLC to use.
protected  org.apache.tools.ant.types.Commandline cmdl
           
protected  boolean compile
          Set whether or not to have XMLC compile the generated Java file.
protected  java.io.File destDir
          The destination directory into which the generated classes are written.
protected  boolean forceBuild
          Force XMLC to always re-process the ML code (or not)
protected  boolean keep
          Set whether or not to keep the generated Java file.
protected static java.lang.String logHdr
           
protected  int logLevel
           
protected  java.lang.String ML
          The kind of markup language being processed
protected  java.lang.String options
          The name of options file to add parameters to the XMLC command
protected  java.lang.String packageDir
          Expressed as a directory path, either '/' or '\' are accepted.
protected  java.lang.String packageName
          Set the package prefix for generated classes
protected  java.lang.String performExec
           
protected  boolean recompile
          Generates support for automatic class recompilation
protected  boolean reloading
          Specifies what XMLC generates
protected  java.io.File srcDir
          The directory containing the HTML files
protected  java.lang.String srcDirName
          The name of the directory containing the HTML files
protected  java.io.File srcOutDir
          The destination directory into which the generated sources are written
protected  java.lang.String srcOutDirName
          The destination directory into which the generated sources are written
protected  int upToDate
           
protected  boolean verbose
          Set "true" for -verbose
protected  java.lang.String xmlcArgs
           
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset, useDefaultExcludes
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Xmlc()
           
 
Method Summary
 void copyFile(java.io.File sourceFile, java.io.File destFile, boolean overwrite)
          copy file from source to destination
 org.apache.tools.ant.types.Commandline.Argument createArg()
          Set nested arguments to the XMLC command to be executed.
 void execute()
          Required by ant framework - implements execute() in Task.
 void setArgs(java.lang.String args)
          Set nested arguments to the XMLC command to be executed
 void setClasspath(java.lang.String classpath)
          Set the classpath for the XMLC compiler
 void setCompile(Xmlc.BooleanAttribute _compile)
          Set whether or not to have XMLC compile the generated Java file.
 void setDestdir(java.lang.String destDirName)
          Set the destination directory into which the generated classes are written.
 void setForce(java.lang.String force)
          Force XMLC to always re-process the ML code (or not)
 void setKeep(Xmlc.BooleanAttribute _keep)
          Set whether or not to keep the generated Java file.
 void setMarkup(java.lang.String markup)
          The kind of markup language being processed.
 void setOptions(java.lang.String _options)
          Set whether or not to have XMLC compile the generated Java file.
 void setPackagedir(java.lang.String packagedir)
          Set the Package prefix for generated classes.
 void setPackagename(java.lang.String packagename)
          Set the package prefix for generated classes, while preserving any source file directory paths.
 void setPerformexec(java.lang.String _performExec)
          Set whether or not to invoke XMLC by using Runtime.exec() to create a seperate JVM.
 void setRecomp(Xmlc.BooleanAttribute recomp)
          Generates support for automatic class recompilation; the information is stored in a file with an .xmlc suffix appended to the class name, as specified with the -class option.
 void setReload(Xmlc.BooleanAttribute reload)
          Specifies what XMLC generates: class: XMLC generates a class that does not depend on an interface (default). interface: XMLC generates only an interface. both: XMLC generates both an interface and an implementation class.
 void setSourceout(java.lang.String sourceout)
          Set the destination directory into which the generated source .java files are written, if -keep is used.
 void setSrcdir(java.lang.String srcdirname)
          Set the source directory containing the HTML files.
 void setVerbose(Xmlc.BooleanAttribute _verbose)
          Run XMLC in verbose mode (-verbose flag)
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
addAnd, addContains, addCustom, addDate, addDepend, addDepth, addFilename, addMajority, addNone, addNot, addOr, addPresent, addSelector, addSize, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, isInvalid, log, log, markInvalid, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logHdr

protected static java.lang.String logHdr

srcDir

protected java.io.File srcDir
The directory containing the HTML files

destDir

protected java.io.File destDir
The destination directory into which the generated classes are written.

srcOutDir

protected java.io.File srcOutDir
The destination directory into which the generated sources are written

classPath

protected java.lang.String classPath
The classpath for XMLC to use.

packageDir

protected java.lang.String packageDir
Expressed as a directory path, either '/' or '\' are accepted.

packageName

protected java.lang.String packageName
Set the package prefix for generated classes

srcDirName

protected java.lang.String srcDirName
The name of the directory containing the HTML files

srcOutDirName

protected java.lang.String srcOutDirName
The destination directory into which the generated sources are written

options

protected java.lang.String options
The name of options file to add parameters to the XMLC command

xmlcArgs

protected java.lang.String xmlcArgs

verbose

protected boolean verbose
Set "true" for -verbose

forceBuild

protected boolean forceBuild
Force XMLC to always re-process the ML code (or not)

logLevel

protected int logLevel

upToDate

protected int upToDate

performExec

protected java.lang.String performExec

ML

protected java.lang.String ML
The kind of markup language being processed

keep

protected boolean keep
Set whether or not to keep the generated Java file.

compile

protected boolean compile
Set whether or not to have XMLC compile the generated Java file.

cmdl

protected org.apache.tools.ant.types.Commandline cmdl

recompile

protected boolean recompile
Generates support for automatic class recompilation

reloading

protected boolean reloading
Specifies what XMLC generates
Constructor Detail

Xmlc

public Xmlc()
Method Detail

createArg

public org.apache.tools.ant.types.Commandline.Argument createArg()
Set nested arguments to the XMLC command to be executed.

setArgs

public void setArgs(java.lang.String args)
Set nested arguments to the XMLC command to be executed

setClasspath

public void setClasspath(java.lang.String classpath)
Set the classpath for the XMLC compiler

setCompile

public void setCompile(Xmlc.BooleanAttribute _compile)
Set whether or not to have XMLC compile the generated Java file.

setDestdir

public void setDestdir(java.lang.String destDirName)
Set the destination directory into which the generated classes are written.

setForce

public void setForce(java.lang.String force)
Force XMLC to always re-process the ML code (or not)

setKeep

public void setKeep(Xmlc.BooleanAttribute _keep)
Set whether or not to keep the generated Java file.

setMarkup

public void setMarkup(java.lang.String markup)
The kind of markup language being processed. Choices currently include HTML, WML, XHTML, CHTML and VoiceXML. The generated class is suffixed with this value.

setOptions

public void setOptions(java.lang.String _options)
Set whether or not to have XMLC compile the generated Java file.

setPackagedir

public void setPackagedir(java.lang.String packagedir)
Set the Package prefix for generated classes. Expressed as a directory path.

setPackagename

public void setPackagename(java.lang.String packagename)
Set the package prefix for generated classes, while preserving any source file directory paths. This is useful if you want to take source (markup language) files from one tree, but generate the Java code into another tree, preserving relative paths. For example, suppose that you have .html files under a directory called "discRack/resources", and you want to generate Java code under "discRack/src", but have the package name be "a.b". The following Xmlc taskdef will achieve this: A markup file located at "discRack/resources/c/d/discRack.ml" will be generated to "discRack/src/a/b/c/d/discRackML.java" and will start with a "package a.b.c.d" statement.

setPerformexec

public void setPerformexec(java.lang.String _performExec)
Set whether or not to invoke XMLC by using Runtime.exec() to create a seperate JVM. This capability was originally written to get around a problem with name-space clashes between packages. Set this to the command to execute.

setSourceout

public void setSourceout(java.lang.String sourceout)
Set the destination directory into which the generated source .java files are written, if -keep is used.

setSrcdir

public void setSrcdir(java.lang.String srcdirname)
Set the source directory containing the HTML files.

setVerbose

public void setVerbose(Xmlc.BooleanAttribute _verbose)
Run XMLC in verbose mode (-verbose flag)

setRecomp

public void setRecomp(Xmlc.BooleanAttribute recomp)
Generates support for automatic class recompilation; the information is stored in a file with an .xmlc suffix appended to the class name, as specified with the -class option. Implies the -generate both option.

setReload

public void setReload(Xmlc.BooleanAttribute reload)
Specifies what XMLC generates: class: XMLC generates a class that does not depend on an interface (default). interface: XMLC generates only an interface. both: XMLC generates both an interface and an implementation class. The implementation has the suffix Impl appended to the class name, and uses the class name specified with the -class option. implementation: XMLC generates the class that implements the interface, but not the interface.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Required by ant framework - implements execute() in Task. Called by the project to let the task do its work
Overrides:
execute in class org.apache.tools.ant.Task

copyFile

public void copyFile(java.io.File sourceFile,
                     java.io.File destFile,
                     boolean overwrite)
              throws java.io.IOException
copy file from source to destination