2021SC@SDUSC
ant包
FreemarkerXmlTask.java
代码分析
execute()方法
@Override
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());
}
log("Transforming into: " + destDir.getAbsolutePath(), Project.MSG_INFO);
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();
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());
}
list = scanner.getIncludedFiles();
for (int i = 0; i < list.length; ++i) {
process(baseDir, list[i], destDir);
}
}
JythonAntTask.java
UnlinkedJythonOperations.java
UnlinkedJythonOperationsImpl.java
|