File locking issue on Windows

I have this in my build.gradle file for functionalTest task
task functionalTest(type: Test) {
println “***** functionalTest "
testClassesDir = sourceSets.functionalTest.output.classesDir
classpath = sourceSets.functionalTest.runtimeClasspath + files(”${rootProject.projectDir}")

I"m getting this error in the stacktrace:
Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file

If I change classpath to this it works fine:
classpath = sourceSets.functionalTest.runtimeClasspath

I’m trying to figure out why adding the + files("${rootProject.projectDir}") causes the file locking problem and how to avoid it.


Gradle 4.10.2

Build time: 2018-09-19 18:10:15 UTC
Revision: b4d8d5d170bb4ba516e88d7fe5647e2323d791dd

Kotlin DSL: 1.0-rc-6
Kotlin: 1.2.61
Groovy: 2.4.15
Ant: Apache Ant™ version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_161 (Oracle Corporation 25.161-b12)
OS: Windows 10 10.0 amd64

Your description reminds me a lot of the rogue Gradle daemon issues I get sometimes.

The way I’ve resolved it when I’ve gotten that, is to do a gradle --status to get the PIDs of all Gradle daemons. Then in Task Manager, I kill all the java processes (End Process button) with the corresponding PIDs.

Drastic maybe. But it’s worked like a charm whenever Gradle gets into a similar state on me.