Steven
E.
diff --git a/docs/manual/CoreTasks/loadfile.html b/docs/manual/CoreTasks/loadfile.html
index 711045a3f..97c12a195 100644
--- a/docs/manual/CoreTasks/loadfile.html
+++ b/docs/manual/CoreTasks/loadfile.html
@@ -59,6 +59,17 @@ current locale is used.
Whether to halt the build on failure |
No, default "true" |
+
+ quiet |
+ Do not display a diagnostic message (unless Ant has been
+ invoked with the -verbose or -debug
+ switches) or modify the exit status to reflect an error. Setting this to
+ "true" implies setting failonerror to "false".
+ Since Ant 1.7.0.
+ |
+ No, default "false" |
+
+
The LoadFile task supports nested
diff --git a/docs/manual/CoreTasks/loadresource.html b/docs/manual/CoreTasks/loadresource.html
index 627bc77ea..033d3ad4a 100755
--- a/docs/manual/CoreTasks/loadresource.html
+++ b/docs/manual/CoreTasks/loadresource.html
@@ -58,6 +58,15 @@ element resource collections.
Whether to halt the build on failure |
No, default "true" |
+
+ quiet |
+ Do not display a diagnostic message (unless Ant has been
+ invoked with the -verbose or -debug
+ switches) or modify the exit status to reflect an error. Setting this to
+ "true" implies setting failonerror to "false".
+ |
+ No, default "false" |
+
The LoadResource task supports nested
diff --git a/src/main/org/apache/tools/ant/taskdefs/LoadResource.java b/src/main/org/apache/tools/ant/taskdefs/LoadResource.java
index dd2b68647..500b857a6 100755
--- a/src/main/org/apache/tools/ant/taskdefs/LoadResource.java
+++ b/src/main/org/apache/tools/ant/taskdefs/LoadResource.java
@@ -50,6 +50,12 @@ public class LoadResource extends Task {
*/
private boolean failOnError = true;
+ /**
+ * suppress error message if it goes pear-shaped, sets failOnError=false
+ */
+ private boolean quiet = false;
+
+
/**
* Encoding to use for filenames, defaults to the platform's default
* encoding.
@@ -100,7 +106,18 @@ public class LoadResource extends Task {
public final void setFailonerror(final boolean fail) {
failOnError = fail;
}
-
+
+ /**
+ * If true, suppress the load error report and set the
+ * the failonerror value to true.
+ * @param quiet The new Quiet value
+ */
+ public void setQuiet(final boolean quiet) {
+ this.quiet = quiet;
+ if (quiet) {
+ this.failOnError = false;
+ }
+ }
/**
* read in a source file to a property
@@ -116,12 +133,16 @@ public class LoadResource extends Task {
if (property == null) {
throw new BuildException("output property not defined");
}
+ if (quiet && failOnError) {
+ throw new BuildException("quiet and failonerror cannot both be "
+ + "set to true");
+ }
if (!src.isExists()) {
String message = src + " doesn't exist";
if (failOnError) {
throw new BuildException(message);
} else {
- log(message, Project.MSG_ERR);
+ log(message, quiet ? Project.MSG_WARN : Project.MSG_ERR);
return;
}
}
@@ -175,13 +196,14 @@ public class LoadResource extends Task {
if (failOnError) {
throw new BuildException(message, ioe, getLocation());
} else {
- log(message, Project.MSG_ERR);
+ log(message, quiet ? Project.MSG_VERBOSE : Project.MSG_ERR);
}
} catch (final BuildException be) {
if (failOnError) {
throw be;
} else {
- log(be.getMessage(), Project.MSG_ERR);
+ log(be.getMessage(),
+ quiet ? Project.MSG_VERBOSE : Project.MSG_ERR);
}
} finally {
FileUtils.close(is);