From 18897c517af55f7072a63c838e15c3fe7358e6cd Mon Sep 17 00:00:00 2001 From: Magesh Umasankar Date: Thu, 27 Dec 2001 21:47:17 +0000 Subject: [PATCH] Delegate validation to DestDir. This has a nice effect on MkDir as at least one 'unknown reason' (Path containing an existing non-directory element) will be known by using DestDir. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270386 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Mkdir.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Mkdir.java b/src/main/org/apache/tools/ant/taskdefs/Mkdir.java index f685c2fb9..e78f628b7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Mkdir.java +++ b/src/main/org/apache/tools/ant/taskdefs/Mkdir.java @@ -54,9 +54,10 @@ package org.apache.tools.ant.taskdefs; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.BuildException; import java.io.File; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.DestDir; /** @@ -74,10 +75,6 @@ public class Mkdir extends Task { throw new BuildException("dir attribute is required", location); } - if (dir.isFile()) { - throw new BuildException("Unable to create directory as a file already exists with that name: " + dir.getAbsolutePath()); - } - if (!dir.exists()) { boolean result = dir.mkdirs(); if (result == false) { @@ -89,7 +86,19 @@ public class Mkdir extends Task { } } + /** + * @deprecated setDir(File) is deprecated and is replaced with + * setDir(DestDir) to let Ant's core perform validation + */ public void setDir(File dir) { - this.dir = dir; + log("DEPRECATED - The setDir(File) method has been deprecated." + + " Use setDir(DestDir) instead."); + DestDir destDir = new DestDir(); + destDir.setFile(dir); + setDir(destDir); + } + + public void setDir(DestDir destDir) { + this.dir = destDir.getFile(); } }