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