|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.enhydra.xml.xmlc.taskdef.Xmlc
ANT task to invoke the XMLC compiler to generate Java code.
Implements an Ant taskdef to perform XMLC compilations. Please refer to the Ant website for more information. XMLCTask extends MatchingTask which means that it has the ability to include or exclude files based on pattern matching. The supported tags are as follows:
tag | required | default value | description |
---|---|---|---|
srcdir | yes | The source directory root | |
destdir | no | The destination directory root. Only really useful if you want XMLC to do the compilation, so we can check dependencies. | |
packagedir | no | blank package | Package prefix for generated classes, expressed as a directory path. If not specified, the relative path from srcdir becomes the package. |
markup | no | HTML | The kind of markup language being processed. Choices currently include HTML, WML, XHTML, CHTML and VoiceXML. The generated class is suffixed with this value |
verbose | no | no | Displays the XMLC command and all of the arguments |
compile | no | no | 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 |
keep | no | yes | 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. |
performExec | no | no | XMLC is invoked by performing a Runtime.exec() (kept for historical reasons by the author) |
options | no | File name of XMLC options or a glob style pattern. | |
arg | no | 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 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 |
Inner Class Summary | |
static class |
Xmlc.BooleanAttribute
|
Field Summary | |
protected String |
classPath
|
protected org.enhydra.xml.xmlc.taskdef.Commandline |
cmdl
|
protected boolean |
compile
|
protected File |
destDir
|
protected boolean |
forceBuild
|
protected boolean |
keep
|
protected static String |
logHdr
|
protected int |
logLevel
|
protected String |
ML
|
protected String |
options
|
protected String |
packageDir
|
protected String |
packageName
|
protected String |
performExec
|
protected File |
srcDir
|
protected String |
srcDirName
|
protected File |
srcOutDir
|
protected String |
srcOutDirName
|
protected int |
upToDate
|
protected boolean |
verbose
|
protected String |
xmlcArgs
|
Constructor Summary | |
Xmlc()
|
Method Summary | |
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(String args)
Deprecated. Use <arg> tags for now, this will eventually be removed. |
void |
setClasspath(String classpath)
Deprecated. Use nested |
void |
setCompile(Xmlc.BooleanAttribute _compile)
Set whether or not to have XMLC compile the generated Java file. |
void |
setDestdir(String destDirName)
Set the destination directory into which the generated classes are written. |
void |
setForce(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(String markup)
The kind of markup language being processed. |
void |
setOptions(String _options)
Set to a specific options file to add parameters to the XMLC command. |
void |
setPackagedir(String packagedir)
Set the Package prefix for generated classes. |
void |
setPackagename(String packagename)
Set the package prefix for generated classes, while preserving any source file directory paths. |
void |
setPerformexec(String _performExec)
Set whether or not to invoke XMLC by using Runtime.exec() to create a seperate JVM. |
void |
setSourceout(String sourceout)
Set the destination directory into which the generated source .java files are written, if -keep is used. |
void |
setSrcdir(String srcdirname)
Set the source directory containing the HTML files. |
void |
setVerbose(Xmlc.BooleanAttribute _verbose)
Run XMLC in verbose mode (-verbose flag) |
Field Detail |
protected static String logHdr
protected File srcDir
protected File destDir
protected File srcOutDir
protected String classPath
protected String packageDir
protected String packageName
protected String srcDirName
protected String srcOutDirName
protected String options
protected String xmlcArgs
protected boolean verbose
protected boolean forceBuild
protected int logLevel
protected int upToDate
protected String performExec
protected String ML
protected boolean keep
protected boolean compile
protected org.enhydra.xml.xmlc.taskdef.Commandline cmdl
Constructor Detail |
public Xmlc()
Method Detail |
public void setSrcdir(String srcdirname)
srcDirName
- The name of the directory containing the HTML filespublic void setDestdir(String destDirName)
destDirName
- The destination directory into which the generated classes are written.public void setForce(String force)
public void setArgs(String args)
args
- The XMLC options to be passed through.public void setClasspath(String classpath)
classpath
- The classpath for XMLC to use.public void setSourceout(String sourceout)
sourceout
- The destination directory into which the generated sources are written.
Note: Currently -keep is used by devault since the .java files are best
compiled by the built-in Ant javac command as a separate rule.public void setVerbose(Xmlc.BooleanAttribute _verbose)
_verbose
- Set "true" for -verbose, anything else (e.g. "false") for
quiet mode.public void setPackagedir(String packagedir)
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.
packagedir
- Expressed as a directory path, either '/' or '\' are accepted.setPackagename(String)
public void setPackagename(String packagename)
For example, suppose that you have .html files under a directory called "foo/resources", and you want to generate Java code under "foo/source", but have the package name be "a.b". The following Xmlc taskdef will achieve this:
A markup file located at "foo/resources/c/d/Foo.ml" will be generated to "foo/source/a/b/c/d/FooML.java" and will start with a "package a.b.c.d" statement.
public void setMarkup(String markup)
markup
- The type of markup language (controls only the file-name suffix,
the actual markup is controlled through the XMLC -dom option which is accessible
through the "args" option or <arg> tag.public void setPerformexec(String _performExec)
performExec
- Set to "true" or "false"public void execute() throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
- All exceptions are thrown as BuildException.
Note: most of the logic here was cloned from the Javac command. Unfortunately
this was the only way to 'reuse' it.public void setKeep(Xmlc.BooleanAttribute _keep)
keep
- Set to "true" or "false"public void setCompile(Xmlc.BooleanAttribute _compile)
compile
- Set to "true" or "false"public void setOptions(String _options)
options
- Set to file name or glob patternpublic Commandline.Argument createArg()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |