I use the groovy AntBuilder in a custom written installer, eg. to unpack the installation package. One thing I cannot figure out, is how to detect, whether the unzip task failed, eg. I have the following code:
...
AntBuilder antBuilder = new AntBuilder()
antBuilder.mkdir(dir:installationPath)
antBuilder.unzip(src:zipFileName, dest:installationPath,overwrite:"yes")
...
If the destination path ("installationPath") is write protected, the unzip reports errors ("unable to expand..."), but the task itself does not fail. There is also no "failOnError" attribute for unzip.
Is there a way to force a unzip task to fail, if the target is writeprotected (or the drive is full, etc.)?
It seems there is no way to catch the exception.
According to the source code from ant
protected void extractFile(FileUtils fileUtils, File srcF, File dir,
InputStream compressedInputStream,
String entryName, Date entryDate,
boolean isDirectory, FileNameMapper mapper)
throws IOException {
...........................
...........................
...........................
} catch (FileNotFoundException ex) {
log("Unable to expand to file " + f.getPath(),
ex,
Project.MSG_WARN);
}
}
It silently catches the exception without re-throwing it further.