Browse Source

Bugzilla 38249: add quiet to loadfile

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@474520 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
b9bf508d0c
6 changed files with 54 additions and 4 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +11
    -0
      docs/manual/CoreTasks/loadfile.html
  5. +9
    -0
      docs/manual/CoreTasks/loadresource.html
  6. +26
    -4
      src/main/org/apache/tools/ant/taskdefs/LoadResource.java

+ 1
- 0
CONTRIBUTORS View File

@@ -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


+ 3
- 0
WHATSNEW View File

@@ -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
=========================================== ===========================================




+ 4
- 0
contributors.xml View File

@@ -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>


+ 11
- 0
docs/manual/CoreTasks/loadfile.html View File

@@ -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">


+ 9
- 0
docs/manual/CoreTasks/loadresource.html View File

@@ -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">


+ 26
- 4
src/main/org/apache/tools/ant/taskdefs/LoadResource.java View File

@@ -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);


Loading…
Cancel
Save