From 4a8cd1490b700125218abd9d6de8e09ed3fbaa59 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 11 Apr 2002 07:03:11 +0000 Subject: [PATCH] Make sure the implicit fileset in knows the current project. Don't remove things that have never been added. Share secret knowledge of wise old (wo)men. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272359 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Chmod.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Chmod.java b/src/main/org/apache/tools/ant/taskdefs/Chmod.java index 52fd562d4..687c590a8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Chmod.java +++ b/src/main/org/apache/tools/ant/taskdefs/Chmod.java @@ -58,6 +58,7 @@ import java.io.File; import java.io.IOException; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.condition.Os; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.FileSet; @@ -84,6 +85,14 @@ public class Chmod extends ExecuteOn { super.setSkipEmptyFilesets(true); } + /** + * @see ProjectComponent#setProject + */ + public void setProject(Project project) { + super.setProject(project); + defaultSet.setProject(project); + } + public void setFile(File src) { FileSet fs = new FileSet(); fs.setDir(new File(src.getParent())); @@ -171,11 +180,19 @@ public class Chmod extends ExecuteOn { } public void execute() throws BuildException { + /* + * In Ant 1.1, means, change the permissions + * of directory foo, not anything inside of it. This is the case the + * second branch of the if statement below catches for backwards + * compatibility. + */ if (defaultSetDefined || defaultSet.getDir(project) == null) { try { super.execute(); } finally { - filesets.removeElement(defaultSet); + if (defaultSetDefined && defaultSet.getDir(project) != null) { + filesets.removeElement(defaultSet); + } } } else if (isValidOs()) { // we are chmodding the given directory