Help needed with gradle clean failure

Hi,

Issue - I am repeatedly facing failures while running gradlew clean on a project. However, I am able to successfully execute other gradle tasks like run, build, test, assemble etc.
Version details:
Gradle: 8.5
JDK: 11

I have tried using Intellij Idea IDE as well as used linux command line (using ./gradlew) and same issue persists.

$ ./gradlew clean
=======================================
OpenSearch Build Hamster says Hello!
  Gradle Version        : 8.5
  OS Info               : Linux 5.15.133.1-microsoft-standard-WSL2 (amd64)
  JDK Version           : 11 (Ubuntu JDK)
  JAVA_HOME             : /usr/lib/jvm/java-11-openjdk-amd64
  Random Testing Seed   : 49523C34CF97B63A
  In FIPS 140 mode      : false
=======================================
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in theGradle documentation.

BUILD SUCCESSFUL in 57s
2 actionable tasks: 1 executed, 1 up-to-date

FAILURE: Build failed with an exception.
* What went wrong:
Failed to release lock on Compressed Files Expansion Cache (/<project-dir-full-path>/build/tmp/.cache/expanded)
> No such file or directory
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in theGradle documentation.
BUILD FAILED in 57s

I have tried the following

  • Cleaned up gradle cache(.gradle/caches) , .gradle from the project location and also from the user’s home directory.
  • Stopped gradle daemon using gradlew --stop

What could be the reason for this failure and how to avoid this?
Is this an environment related issue or something to do with the project?

Any help would be greatly appreciated!
Thanks

This seems to be a regression in Gradle 8 I’d say.

If I simply put this to a build script:

val foo by configurations.creating
dependencies {
    foo("commons-lang:commons-lang:+")
}
zipTree(foo.singleFile).visit { }

then clean on Windows will fail to delete files in build/tmp/.cache/expanded/expanded.lock, while clean on Linux will behave exactly like you posted.

With Gradle 7.6.4 this works just fine, with 8.0.2 it fails.

You should report this as regression and post the link here for reference if there is no issue yet.

It indeed is already reported at Undeletable files on Windows when `ArchiveOperations.zipTree` is used inside a TransformAction · Issue #25752 · gradle/gradle · GitHub and also already fixed in 8.7-rc-1.

Thank you for the response. My project is still on 8.5. I’ll update to 8.7.* when possible and share feedback here.
Meanwhile, are you aware of any workaround that can still resolve this for lower versions?

I’m not sure, probably not using zipTree and tarTree during configuration time if possible (iterating the actual files).
Iirc I first tried at execution time and it worked there.
But I may also misremember right now.

Other than that, or if it does not help or is not possible, probably just downgrading to Gradle 7.