This is an automated email from the ASF dual-hosted git repository. jaikiran pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ant.git
commit fe3727ee48b5ff89f65de52dea91c1bc757e4705 Author: Jaikiran Pai <jaiki...@apache.org> AuthorDate: Tue Jul 1 19:28:59 2025 +0530 FileUtils.tryHardToDelete() - On Windows, mark the file writable if it's read-only, before retrying File.delete() --- src/main/org/apache/tools/ant/util/FileUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index 087ab703d..824820233 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -1754,6 +1754,11 @@ public class FileUtils { */ public boolean tryHardToDelete(File f, boolean runGC) { if (!f.delete()) { + // If the file is read-only on Windows, then it cannot be deleted. + // We set it to writable and then retry to delete it. + if (!f.canWrite() && ON_WINDOWS) { + final boolean ignored = f.setWritable(true); + } if (runGC) { System.gc(); }