if (destfile.exists() && (!destfile.canWrite() || !destfile.isFile())) {
throw new BuildException("Unable to write to destination file");
}
final SessionInfoStore infoStore = new SessionInfoStore();
final ExecutionDataStore dataStore = new ExecutionDataStore();
loadSourceFiles(infoStore, dataStore);
OutputStream outputStream = null;
try {
FileUtils.getFileUtils().createNewFile(destfile, true);
outputStream = new BufferedOutputStream(new FileOutputStream(
destfile));
final ExecutionDataWriter dataWriter = new ExecutionDataWriter(
outputStream);
infoStore.accept(dataWriter);
dataStore.accept(dataWriter);
} catch (final IOException e) {
throw new BuildException(String.format(
"Unable to write merged file %s", destfile.getName()), e);
} finally {
FileUtils.close(outputStream);