diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java index 269b1b73f..12d3d3d50 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ b/src/main/org/apache/tools/ant/taskdefs/Expand.java @@ -133,6 +133,12 @@ public class Expand extends Task { log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); ZipFile zf = null; FileNameMapper mapper = getMapper(); + if (!srcF.exists()) { + throw new BuildException("Unable to expand " + + srcF + + " as the file does not exist", + getLocation()); + } try { zf = new ZipFile(srcF, encoding); Enumeration e = zf.getEntries(); @@ -296,7 +302,9 @@ public class Expand extends Task { fileUtils.setFileLastModified(f, entryDate.getTime()); } catch (FileNotFoundException ex) { - log("Unable to expand to file " + f.getPath(), Project.MSG_WARN); + log("Unable to expand to file " + f.getPath(), + ex, + Project.MSG_WARN); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Untar.java b/src/main/org/apache/tools/ant/taskdefs/Untar.java index 3a864c855..9f603067a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Untar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Untar.java @@ -39,8 +39,6 @@ import org.apache.tools.tar.TarInputStream; /** * Untar a file. - *

For JDK 1.1 "last modified time" field is set to current time instead of being - * carried from the archive file.

*

PatternSets are used to select files to extract * from the archive. If no patternset is used, all files are extracted. *

@@ -94,11 +92,18 @@ public class Untar extends Expand { /** {@inheritDoc} */ protected void expandFile(FileUtils fileUtils, File srcF, File dir) { FileInputStream fis = null; + if (!srcF.exists()) { + throw new BuildException("Unable to untar " + + srcF + + " as the file does not exist", + getLocation()); + } try { fis = new FileInputStream(srcF); expandStream(srcF.getPath(), fis, dir); } catch (IOException ioe) { - throw new BuildException("Error while expanding " + srcF.getPath(), + throw new BuildException("Error while expanding " + srcF.getPath() + + "\n" + ioe.toString(), ioe, getLocation()); } finally { FileUtils.close(fis);