- a href="http://fmpp.sourceforge.net">FMPP is a more complete solution.
| Attribute |
Description |
Required |
| basedir |
location of the XML files. Defaults to the project's
basedir. |
No |
| destdir |
location to store the generated files. |
Yes |
| includes |
comma-separated list of patterns of files that must be
included; all files are included when omitted. |
No |
| includesfile |
the name of a file that contains
include patterns. |
No |
| excludes |
comma-separated list of patterns of files that must be
excluded; no files (except default excludes) are excluded when omitted. |
No |
| excludesfile |
the name of a file that contains
exclude patterns. |
No |
| defaultexcludes |
indicates whether default excludes should be used
(yes | no); default excludes are used when omitted. |
No |
| extension |
extension of generated files. Defaults to .html. |
No |
| template |
name of the FreeMarker template file that will be
applied by default to XML files |
No |
| templateDir |
location of the FreeMarker template(s) to be used, defaults
to the project's baseDir |
No |
| projectfile |
path to the project file. The poject file must be an XML file.
If omitted, it will not be available to templates |
No |
| incremental |
indicates whether all files should be regenerated (no), or
only those that are older than the XML file, the template file, or the
project file (yes). Defaults to yes. |
No |
| encoding |
The encoding of the output files. Defaults to platform
default encoding. |
No |
| templateEncoding |
The encoding of the template files. Defaults to platform
default encoding. |
No |
| validation |
Whether to validate the XML input. Defaults to off. |
No |
| models |
A list of [name=]className pairs separated by spaces,
commas, or semicolons that specifies further models that should be
available to templates. If name is omitted, the unqualified class name
is used as the name. Every class that is specified must implement the
TemplateModel interface and have a no-args constructor. |
No |
| Method from freemarker.ext.ant.FreemarkerXmlTask Detail: |
public void addConfiguredJython(JythonAntTask jythonAntTask) {
this.prepareEnvironment = jythonAntTask;
} Deprecated! |
public void addConfiguredPrepareEnvironment(JythonAntTask prepareEnvironment) {
this.prepareEnvironment = prepareEnvironment;
} Deprecated! |
public void addConfiguredPrepareModel(JythonAntTask prepareModel) {
this.prepareModel = prepareModel;
} Deprecated! |
public void execute() throws BuildException {
DirectoryScanner scanner;
String[] list;
if (baseDir == null)
{
baseDir = getProject().getBaseDir();
}
if (destDir == null )
{
String msg = "destdir attribute must be set!";
throw new BuildException(msg, getLocation());
}
File templateFile = null;
if (templateDir == null) {
if (templateName != null) {
templateFile = new File(templateName);
if (!templateFile.isAbsolute()) {
templateFile = new File(getProject().getBaseDir(), templateName);
}
templateDir = templateFile.getParentFile();
templateName = templateFile.getName();
}
else {
templateDir = baseDir;
}
setTemplateDir(templateDir);
} else if (templateName != null) {
if (new File(templateName).isAbsolute()) {
throw new BuildException("Do not specify an absolute location for the template as well as a templateDir");
}
templateFile = new File(templateDir, templateName);
}
if (templateFile != null) {
templateFileLastModified = templateFile.lastModified();
}
try {
if (templateName != null) {
parsedTemplate = cfg.getTemplate(templateName, templateEncoding);
}
}
catch (IOException ioe) {
throw new BuildException(ioe.toString());
}
// get the last modification of the template
log("Transforming into: " + destDir.getAbsolutePath(), Project.MSG_INFO);
// projectFile relative to baseDir
if (projectAttribute != null && projectAttribute.length() > 0)
{
projectFile = new File(baseDir, projectAttribute);
if (projectFile.isFile())
projectFileLastModified = projectFile.lastModified();
else
{
log ("Project file is defined, but could not be located: " +
projectFile.getAbsolutePath(), Project.MSG_INFO );
projectFile = null;
}
}
generateModels();
// find the files/directories
scanner = getDirectoryScanner(baseDir);
propertiesTemplate = wrapMap(project.getProperties());
userPropertiesTemplate = wrapMap(project.getUserProperties());
builderFactory.setValidating(validation);
try
{
builder = builderFactory.newDocumentBuilder();
}
catch(ParserConfigurationException e)
{
throw new BuildException("Could not create document builder", e, getLocation());
}
// get a list of files to work on
list = scanner.getIncludedFiles();
for (int i = 0;i < list.length; ++i)
{
process(baseDir, list[i], destDir);
}
} Deprecated! |
protected void insertDefaults(Map root) {
root.put("properties", propertiesTemplate);
root.put("userProperties", userPropertiesTemplate);
if (projectTemplate != null) {
root.put("project", projectTemplate);
root.put("project_node", projectNode);
}
if(modelsMap.size() > 0)
{
for (Iterator it = modelsMap.entrySet().iterator(); it.hasNext();)
{
Map.Entry entry = (Map.Entry) it.next();
root.put(entry.getKey(), entry.getValue());
}
}
} Deprecated! |
public void setBasedir(File dir) {
baseDir = dir;
} Deprecated!Set the base directory. Defaults to . |
public void setDestdir(File dir) {
destDir = dir;
} Deprecated!Set the destination directory into which the generated
files should be copied to |
public void setEncoding(String encoding) {
this.encoding = encoding;
} Deprecated!Set encoding for generated files. Defaults to platform default encoding. |
public void setExtension(String extension) {
this.extension = extension;
} Deprecated!Set the output file extension. .html by default. |
public void setIncremental(String incremental) {
this.incremental = !(incremental.equalsIgnoreCase("false") || incremental.equalsIgnoreCase("no") || incremental.equalsIgnoreCase("off"));
} Deprecated!Turn on/off incremental processing. On by default |
public void setModels(String models) {
this.models = models;
} Deprecated! |
public void setProjectfile(String projectAttribute) {
this.projectAttribute = projectAttribute;
} Deprecated!Set the path to the project XML file |
public void setTemplate(String templateName) {
this.templateName = templateName;
} Deprecated! |
public void setTemplateDir(File templateDir) throws BuildException {
this.templateDir = templateDir;
try {
cfg.setDirectoryForTemplateLoading(templateDir);
} catch (Exception e) {
throw new BuildException(e);
}
} Deprecated! |
public void setTemplateEncoding(String inputEncoding) {
this.templateEncoding = inputEncoding;
} Deprecated! |
public void setValidation(boolean validation) {
this.validation = validation;
} Deprecated!Sets whether to validate the XML input. |