Ran into a weird issue today where I was refactoring a lot of Java classes. Trying to run Gradle build via IntelliJ kept failing.
The error was:
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().
Running with --stacktrace showed this error:
Caused by: java.lang.IllegalStateException: Cannot lock Java compile cache (/projects/myproject/app/.gradle/5.5/javaCompile) as it has already been locked by this process.
I tried shutting down IntelliJ, but running gradle clean build
via the command line gave the same error. Could not delete the /projects/myproject/app/.gradle/javaCompile
folder too.
$ rm -rf javaCompile/
rm: cannot remove 'javaCompile/classAnalysis.bin': Text file busy
rm: cannot remove 'javaCompile/javaCompile.lock': Text file busy
rm: cannot remove 'javaCompile/taskHistory.bin': Text file busy
This was on an Ubuntu VM, so ended up killing all the gradle processes running (I had 3 running ps -ef | grep gradle , followed by kill ), and that finally solved the issue!
🙏