Bug 52106 - delete task is loud even when politely asked to be quiet
Summary: delete task is loud even when politely asked to be quiet
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.2
Hardware: PC Mac OS X 10.4
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Depends on:
Reported: 2011-10-27 21:07 UTC by bmargulies
Modified: 2020-11-07 13:52 UTC (History)
0 users

修复漏洞 (deleted)
2020-11-06 12:10 UTC, admin

Note You need to log in before you can comment on or make changes to this bug.
Description bmargulies 2011-10-27 21:07:27 UTC
<delete file="${wrapper-log-path}" quiet="true" />

leads to:

   [delete] Deleting: /Users/benson/x/oap/it/smoke/target/sandbox/jdd-install/logs/wrapper.log

The doc seems to be telling me that, without a setting of 'verbose="true", it won't talk. Is the doc wrong?
Comment 1 Stefan Bodewig 2011-10-28 10:01:17 UTC
This is tricky.

When deleting a directory tree Ant explicitly logs a "normal" level message for the top level dir and verbose affects the individual files and directories inside the tree.  When you use a single file arg this is considered the same as the top-level of the tree.

The fix is simple

Index: src/main/org/apache/tools/ant/taskdefs/Delete.java
--- src/main/org/apache/tools/ant/taskdefs/Delete.java  (revision 1190217)
+++ src/main/org/apache/tools/ant/taskdefs/Delete.java  (working copy)
@@ -551,7 +551,8 @@
                         + " cannot be removed using the file attribute.  "
                         + "Use dir instead.", quiet ? Project.MSG_VERBOSE : ver
                 } else {
-                    log("Deleting: " + file.getAbsolutePath());
+                    log("Deleting: " + file.getAbsolutePath(),
+                        quiet ? Project.MSG_VERBOSE : verbosity);

                     if (!delete(file)) {
                         handle("Unable to delete file " + file.getAbsolutePath());

but would make the logging logic of that task (even more) inconsistent.

You get the behavior you want by using a nested <file> resource rather than the file attribute.

<delete quiet="true">
  <file file="${wrapper-log-path}" />

Did I say logging already was inconsistent?
Comment 2 admin 2020-11-06 12:10:17 UTC
Created attachment 37547 [details]
Comment 3 Stefan Bodewig 2020-11-07 13:51:40 UTC
Comment on attachment 37547 [details]

some nonsense
Comment 4 Stefan Bodewig 2020-11-07 13:52:41 UTC
The content of attachment 37547 [details] has been deleted for the following reason:

not-working PHP snippet