git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@474520 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -241,6 +241,7 @@ Stephen Goetze | |||||
| Steve Cohen | Steve Cohen | ||||
| Steve Loughran | Steve Loughran | ||||
| Steve Morin | Steve Morin | ||||
| Steve Wadsworth | |||||
| Steven E. Newton | Steven E. Newton | ||||
| Takashi Okamoto | Takashi Okamoto | ||||
| Taoufik Romdhane | Taoufik Romdhane | ||||
| @@ -29,6 +29,9 @@ Other changes: | |||||
| * add dtd to javadoc for junit. | * add dtd to javadoc for junit. | ||||
| Bugzilla 40754. | Bugzilla 40754. | ||||
| * add quiet attribute to loadfile/resource. | |||||
| Bugzilla 38249. | |||||
| Changes from Ant 1.7.0Beta3 to Ant 1.7.0RC1 | Changes from Ant 1.7.0Beta3 to Ant 1.7.0RC1 | ||||
| =========================================== | =========================================== | ||||
| @@ -960,6 +960,10 @@ | |||||
| <first>Steve</first> | <first>Steve</first> | ||||
| <last>Morin</last> | <last>Morin</last> | ||||
| </name> | </name> | ||||
| <name> | |||||
| <first>Steve</first> | |||||
| <last>Wadsworth</last> | |||||
| </name> | |||||
| <name> | <name> | ||||
| <first>Steven</first> | <first>Steven</first> | ||||
| <middle>E.</middle> | <middle>E.</middle> | ||||
| @@ -59,6 +59,17 @@ current locale is used. | |||||
| <td valign="top">Whether to halt the build on failure</td> | <td valign="top">Whether to halt the build on failure</td> | ||||
| <td align="center" valign="top">No, default "true"</td> | <td align="center" valign="top">No, default "true"</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td valign="top">quiet</td> | |||||
| <td valign="top">Do not display a diagnostic message (unless Ant has been | |||||
| invoked with the <code>-verbose</code> or <code>-debug</code> | |||||
| switches) or modify the exit status to reflect an error. Setting this to | |||||
| "true" implies setting failonerror to "false". | |||||
| <em>Since Ant 1.7.0.</em> | |||||
| </td> | |||||
| <td align="center" valign="top">No, default "false"</td> | |||||
| </tr> | |||||
| </table> | </table> | ||||
| <p> | <p> | ||||
| The LoadFile task supports nested <a href="../CoreTypes/filterchain.html"> | The LoadFile task supports nested <a href="../CoreTypes/filterchain.html"> | ||||
| @@ -58,6 +58,15 @@ element resource collections. | |||||
| <td valign="top">Whether to halt the build on failure</td> | <td valign="top">Whether to halt the build on failure</td> | ||||
| <td align="center" valign="top">No, default "true"</td> | <td align="center" valign="top">No, default "true"</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td valign="top">quiet</td> | |||||
| <td valign="top">Do not display a diagnostic message (unless Ant has been | |||||
| invoked with the <code>-verbose</code> or <code>-debug</code> | |||||
| switches) or modify the exit status to reflect an error. Setting this to | |||||
| "true" implies setting failonerror to "false". | |||||
| </td> | |||||
| <td align="center" valign="top">No, default "false"</td> | |||||
| </tr> | |||||
| </table> | </table> | ||||
| <p> | <p> | ||||
| The LoadResource task supports nested <a href="../CoreTypes/filterchain.html"> | The LoadResource task supports nested <a href="../CoreTypes/filterchain.html"> | ||||
| @@ -50,6 +50,12 @@ public class LoadResource extends Task { | |||||
| */ | */ | ||||
| private boolean failOnError = true; | 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 to use for filenames, defaults to the platform's default | ||||
| * encoding. | * encoding. | ||||
| @@ -100,7 +106,18 @@ public class LoadResource extends Task { | |||||
| public final void setFailonerror(final boolean fail) { | public final void setFailonerror(final boolean fail) { | ||||
| failOnError = 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 | * read in a source file to a property | ||||
| @@ -116,12 +133,16 @@ public class LoadResource extends Task { | |||||
| if (property == null) { | if (property == null) { | ||||
| throw new BuildException("output property not defined"); | 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()) { | if (!src.isExists()) { | ||||
| String message = src + " doesn't exist"; | String message = src + " doesn't exist"; | ||||
| if (failOnError) { | if (failOnError) { | ||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| } else { | } else { | ||||
| log(message, Project.MSG_ERR); | |||||
| log(message, quiet ? Project.MSG_WARN : Project.MSG_ERR); | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -175,13 +196,14 @@ public class LoadResource extends Task { | |||||
| if (failOnError) { | if (failOnError) { | ||||
| throw new BuildException(message, ioe, getLocation()); | throw new BuildException(message, ioe, getLocation()); | ||||
| } else { | } else { | ||||
| log(message, Project.MSG_ERR); | |||||
| log(message, quiet ? Project.MSG_VERBOSE : Project.MSG_ERR); | |||||
| } | } | ||||
| } catch (final BuildException be) { | } catch (final BuildException be) { | ||||
| if (failOnError) { | if (failOnError) { | ||||
| throw be; | throw be; | ||||
| } else { | } else { | ||||
| log(be.getMessage(), Project.MSG_ERR); | |||||
| log(be.getMessage(), | |||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_ERR); | |||||
| } | } | ||||
| } finally { | } finally { | ||||
| FileUtils.close(is); | FileUtils.close(is); | ||||