use of org.apache.tools.ant.taskdefs.TempFile in project ant by apache.
the class AggregateTransformer method transform.
/**
* transformation
* @throws BuildException exception if something goes wrong with the transformation.
*/
public void transform() throws BuildException {
checkOptions();
Project project = task.getProject();
TempFile tempFileTask = new TempFile();
tempFileTask.bindToOwner(task);
xsltTask.setXslResource(getStylesheet());
// acrobatic cast.
xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile());
File outputFile;
if (FRAMES.equals(format)) {
// NOSONAR
String tempFileProperty = getClass().getName() + String.valueOf(counter++);
File tmp = FILE_UTILS.resolveFile(project.getBaseDir(), project.getProperty("java.io.tmpdir"));
tempFileTask.setDestDir(tmp);
tempFileTask.setProperty(tempFileProperty);
tempFileTask.execute();
outputFile = new File(project.getProperty(tempFileProperty));
} else {
outputFile = new File(toDir, "junit-noframes.html");
}
xsltTask.setOut(outputFile);
XSLTProcess.Param paramx = xsltTask.createParam();
paramx.setProject(task.getProject());
paramx.setName("output.dir");
paramx.setExpression(toDir.getAbsolutePath());
configureForRedirectExtension();
final long t0 = System.currentTimeMillis();
try {
xsltTask.execute();
} catch (Exception e) {
throw new BuildException("Errors while applying transformations: " + e.getMessage(), e);
}
final long dt = System.currentTimeMillis() - t0;
task.log("Transform time: " + dt + "ms");
if (format.equals(FRAMES)) {
Delete delete = new Delete();
delete.bindToOwner(task);
delete.setFile(outputFile);
delete.execute();
}
}
Aggregations