When a mkdir task contains ".." as directory name, it will not be parsed correctly. Same thing as it happened with Bug #26765. The fix is similar: call the FiltUtils.normalize() to make sure the path is parsed correctly. Patch included. diff -Nurb apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/Mkdir.java apache-ant-1.6.5-fixed/src/main/org/apache/tools/ant/taskdefs/Mkdir.java --- apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/Mkdir.java 2005-06-02 15:19:58.000000000 +0200 +++ apache-ant-1.6.5-fixed/src/main/org/apache/tools/ant/taskdefs/Mkdir.java 2005-10-27 15:26:50.000000000 +0200 @@ -20,6 +20,7 @@ import java.io.File; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; +import org.apache.tools.ant.util.FileUtils; /** * Creates a given directory. @@ -34,6 +35,7 @@ public class Mkdir extends Task { private static final int MKDIR_RETRY_SLEEP_MILLIS = 10; + private static final FileUtils fileUtils = FileUtils.getFileUtils(); /** * our little directory */ @@ -48,6 +50,9 @@ throw new BuildException("dir attribute is required", getLocation()); } + // Normalize file name to make sure ".." are resolved correctly. + dir = fileUtils.normalize(dir.getAbsolutePath()); + if (dir.isFile()) { throw new BuildException("Unable to create directory as a file " + "already exists with that name: "
dir will already be normalized, this happens when Ant translates the string from dir="..." to the File instance passed to setDir. I can't see any problem with stefan@www:~/ASF/ant/ant-HEAD> cat test.xml <project basedir=".."> <mkdir dir="ant-HEAD/../../foo"/> </project> stefan@www:~/ASF/ant/ant-HEAD> ant -f test.xml Buildfile: test.xml [mkdir] Created dir: /home/stefan/ASF/foo BUILD SUCCESSFUL Total time: 1 second