Gradlew in Windows

Here’s a corrected version of your text for a community post, along with a detailed explanation of the problem and potential solutions.

Corrected Community Post Text

Dear Experts,

I’m facing an issue while trying to build a repository using gradlew on Windows. I keep getting the following error: unable to delete file xxxx.jar.

I’ve learned this might be a known issue related to the file system on Windows, as the same process works flawlessly on Linux.

So far, I have tried the following steps without success:

  • Running gradlew clean

  • Excluding my project folder from my antivirus software’s scan

  • Deleting the Gradle cache

  • Using Resource Monitor to check if the file is being used by another process

My build tasks include unzipping an archive, copying files to a new location, and then deleting them from the old one. I suspect that on Windows, Gradle might be too fast, and a subsequent task is trying to delete a file before the previous task (copying) has fully released its lock on it.

What solutions would you recommend for this problem?

Thank you for your help.

It’s fine to use AI to polish your wording, but you should maybe the text the AI directed to you. :smiley:

The error indeed means that something has a lock on the jar file that was not properly closed.
On *nix this is no problem as the filesystem works differently, there just the directory entry is deleted while some process can still have the actual file open and work with it.
On Windows the file cannot be deleted or changed while a lock is open on it.

If no other process has the file descriptor open, it might indeed be your unzipping that has a file descriptor leak.
But without you showing your code, it is hard to guess what you might be doing wrong or finding a proper recommendation.

It is unlikely that “Gradle is too fast” but more that the file descriptor somewhere is not closed properly.
You might for example use some zip input stream that you do not close to extract the jar or something like that, where you should simply use a zipTree and let Gradle do it properly.
But as I said, hard to guess without you showing the problematic code or providing an MCVE.