diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 09573efd7..af4f861d0 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -252,6 +252,7 @@ Rami Ojares Randy Watler Raphael Pierquin Ray Waldin +Remie Bolte Richard Evans Rick Beton Robert Anderson diff --git a/WHATSNEW b/WHATSNEW index 28db72a99..efaec479d 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -919,6 +919,10 @@ Other changes: HTTP connections at the HttpUrlConnection level. Bugzilla Report 41891. + * and (and tasks derived from ) will now create the + parent directory of the destination archive if it doesn't exist. + Bugzilla Report 45377. + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/contributors.xml b/contributors.xml index 30e33ab67..8787c9109 100644 --- a/contributors.xml +++ b/contributors.xml @@ -1030,6 +1030,10 @@ Ray Waldin + + Remie + Bolte + Richard Evans diff --git a/src/main/org/apache/tools/ant/taskdefs/Tar.java b/src/main/org/apache/tools/ant/taskdefs/Tar.java index 31bea1329..2e89c4d19 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tar.java @@ -279,6 +279,12 @@ public class Tar extends MatchingTask { return; } + File parent = tarFile.getParentFile(); + if (parent != null && !parent.isDirectory() && !parent.mkdirs()) { + throw new BuildException("Failed to create missing parent" + + " directory for " + tarFile); + } + log("Building tar: " + tarFile.getAbsolutePath(), Project.MSG_INFO); TarOutputStream tOut = null; diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index c82319dbe..b49ffe28f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -618,6 +618,13 @@ public class Zip extends MatchingTask { if (!state.isOutOfDate()) { return; } + + File parent = zipFile.getParentFile(); + if (parent != null && !parent.isDirectory() && !parent.mkdirs()) { + throw new BuildException("Failed to create missing parent" + + " directory for " + zipFile); + } + updatedFile = true; if (!zipFile.exists() && state.isWithoutAnyResources()) { createEmptyZip(zipFile);