|
|||||||||
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 | |
sourceout | no | value of srcdir | The destination directory into which the generated source *ML.java files are written, if keep="yes". If sourceout is not specified it is set to the value of the srcdir. This will put the *ML.java files in the same location as the .*ml files. |
destdir | no | The destination directory root. Only really useful if you want XMLC to do the compilation, so we can check dependencies. | |
packagedir | no | relative path from srcdir | Package prefix for generated classes, expressed as a directory path (relative to srcdir). Eg... my/package. If not specified, the relative path from srcdir becomes the package. |
packagename | no | blank package | Package prefix for generated classes, while preserving any source file directory paths. For example, given <xmlc srcdir="foo/resources" sourceout="foo/source" packagename="a.b" />, packagename="a.b", 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. |
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 |
force | no | no | Force XMLC to always re-process the ML code whether it has changed or not |
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.apache.tools.ant.types.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 | |
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(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(Xmlc.BooleanAttribute 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 String performExec
protected boolean verbose
protected boolean forceBuild
protected boolean compile
protected boolean keep
protected int logLevel
protected int upToDate
protected String ML
protected org.apache.tools.ant.types.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 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 default since the .java files are best
compiled by the built-in Ant javac command as a separate rule.public void setForce(Xmlc.BooleanAttribute force)
force
- whether to force re-processing of markup or notpublic void setVerbose(Xmlc.BooleanAttribute verbose)
verbose
- Set "true" for -verbose, anything else (e.g. "false") for
quiet mode.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 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:
<xmlc srcdir="foo/resources" sourceout="foo/source" packagename="a.b" />
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.
packagename
- Expressed as a package path, [package].[package]setPackagedir(String)
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
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 org.apache.tools.ant.types.Commandline.Argument createArg()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |