diff --git a/docs/manual/CoreTasks/apply.html b/docs/manual/CoreTasks/apply.html index fb06531e2..26a5de498 100644 --- a/docs/manual/CoreTasks/apply.html +++ b/docs/manual/CoreTasks/apply.html @@ -71,6 +71,13 @@ one mapper element are required.

variables are specified. No, default is false + + skipemptyfilesets + Don't run the command, if no source files have + been found or are newer than their corresponding target + files. + No, default is false + parallel Run the command only once, appending all files as diff --git a/src/main/org/apache/tools/ant/taskdefs/Chmod.java b/src/main/org/apache/tools/ant/taskdefs/Chmod.java index 45814548a..d6426e9a5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Chmod.java +++ b/src/main/org/apache/tools/ant/taskdefs/Chmod.java @@ -77,6 +77,7 @@ public class Chmod extends ExecuteOn { public Chmod() { super.setExecutable("chmod"); super.setParallel(true); + super.setSkipEmptyFilesets(true); } public void setFile(File src) { @@ -194,6 +195,10 @@ public class Chmod extends ExecuteOn { throw new BuildException(taskType+" doesn\'t support the command attribute", location); } + public void setSkipEmptyFilesets(boolean skip) { + throw new BuildException(taskType+" doesn\'t support the skipemptyfileset attribute", location); + } + protected boolean isValidOs() { // XXX if OS=unix return System.getProperty("path.separator").equals(":") diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java index fecbabaf3..58bea1cf4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -73,6 +73,7 @@ public class ExecuteOn extends ExecTask { private boolean parallel = false; protected String type = "file"; protected Commandline.Marker srcFilePos = null; + private boolean skipEmpty = false; /** * Adds a set of files (nested fileset attribute). @@ -95,6 +96,13 @@ public class ExecuteOn extends ExecTask { this.type = type.getValue(); } + /** + * Should empty filesets be ignored? + */ + public void setSkipEmptyFilesets(boolean skip) { + skipEmpty = skip; + } + /** * Marker that indicates where the name of the source file should * be put on the command line. @@ -138,6 +146,12 @@ public class ExecuteOn extends ExecTask { } } + if (v.size() == 0 && skipEmpty) { + log("Skipping fileset for directory " + + base + ". It is empty.", Project.MSG_INFO); + continue; + } + String[] s = new String[v.size()]; v.copyInto(s);