@@ -68,9 +68,10 @@ import java.util.*;
* to provide backwards compatibility for a release. The future position
* to provide backwards compatibility for a release. The future position
* is to use nested filesets exclusively.</p>
* is to use nested filesets exclusively.</p>
*
*
* @author stefano@apache.org
* @author Stefano Mazzocchi <a href="mailto: stefano@apache.org">stefano@apache.org</a>
* @author Tom Dimock <a href="mailto:tad1@cornell.edu">tad1@cornell.edu</a>
* @author Tom Dimock <a href="mailto:tad1@cornell.edu">tad1@cornell.edu</a>
* @author Glenn McAllister <a href="mailto:glennm@ca.ibm.com">glennm@ca.ibm.com</a>
* @author Glenn McAllister <a href="mailto:glennm@ca.ibm.com">glennm@ca.ibm.com</a>
* @author Jon S. Stevens <a href="mailto:jon@latchkey.com">jon@latchkey.com</a>
*/
*/
public class Delete extends MatchingTask {
public class Delete extends MatchingTask {
protected File file = null;
protected File file = null;
@@ -79,6 +80,7 @@ public class Delete extends MatchingTask {
protected boolean usedMatchingTask = false;
protected boolean usedMatchingTask = false;
private int verbosity = Project.MSG_VERBOSE;
private int verbosity = Project.MSG_VERBOSE;
private boolean quiet = false;
/**
/**
* Set the name of a single file to be removed.
* Set the name of a single file to be removed.
@@ -111,6 +113,19 @@ public class Delete extends MatchingTask {
}
}
}
}
/**
* If the file does not exist, do not display a diagnostic
* message or modify the exit status to reflect an error.
* This means that if a file or directory cannot be deleted,
* then no error is reported. This setting emulates the
* -f option to the Unix "rm" command.
* Default is false meaning things are "noisy"
* @param quiet "true" or "on"
*/
public void setQuiet(boolean quiet) {
this.quiet = quiet;
}
/**
/**
* Adds a set of files (nested fileset attribute).
* Adds a set of files (nested fileset attribute).
*/
*/
@@ -218,7 +233,7 @@ public class Delete extends MatchingTask {
} else {
} else {
log("Deleting: " + file.getAbsolutePath());
log("Deleting: " + file.getAbsolutePath());
if (!file.delete()) {
if (!quiet && ! file.delete()) {
throw new BuildException("Unable to delete file " + file.getAbsolutePath());
throw new BuildException("Unable to delete file " + file.getAbsolutePath());
}
}
}
}
@@ -262,13 +277,13 @@ public class Delete extends MatchingTask {
removeDir(f);
removeDir(f);
} else {
} else {
log("Deleting " + f.getAbsolutePath(), verbosity);
log("Deleting " + f.getAbsolutePath(), verbosity);
if (!f.delete()) {
if (!quiet && ! f.delete()) {
throw new BuildException("Unable to delete file " + f.getAbsolutePath());
throw new BuildException("Unable to delete file " + f.getAbsolutePath());
}
}
}
}
}
}
log("Deleting directory " + d.getAbsolutePath(), verbosity);
log("Deleting directory " + d.getAbsolutePath(), verbosity);
if (!d.delete()) {
if (!quiet && ! d.delete()) {
throw new BuildException("Unable to delete directory " + dir.getAbsolutePath());
throw new BuildException("Unable to delete directory " + dir.getAbsolutePath());
}
}
}
}
@@ -279,7 +294,7 @@ public class Delete extends MatchingTask {
for (int j=0; j<files.length; j++) {
for (int j=0; j<files.length; j++) {
File f = new File(d, files[j]);
File f = new File(d, files[j]);
log("Deleting " + f.getAbsolutePath(), verbosity);
log("Deleting " + f.getAbsolutePath(), verbosity);
if (!f.delete()) {
if (!quiet && ! f.delete()) {
throw new BuildException("Unable to delete file " + f.getAbsolutePath());
throw new BuildException("Unable to delete file " + f.getAbsolutePath());
}
}
}
}