UPDATE I just ran through my build process with various versions of Gradle 2: 2.0, 2.1, and 2.2.1. I got the same error with each of them. There has to be something odd about how I’m doing that copy operation, because otherwise copy tasks on Windows machines never would worked!
I have a copy task that is working properly on OSX, Centos, and Ubuntu, but is failing on Windows. The first thing I do is create a list of locations from which I want to copy. This works fine. Then the copy task starts. Here’s the code:
task copyResources(type: Copy) {
from resources
into "${pipelinePath}"
exclude '.*/**'
filter(FixCrLfFilter)
filter(ReplaceTokens, tokens: tokens)
}
The full code is available on my gist.
resources here is the list of locations from which I want to copy. It’s just a list of strings. And here’s where things go horribly horribly wrong. I run gradle (2.2.1) and get this:
D:\Tmp\work\pipeline_1_6dev>gradle
Building pipeline engine to: D:\Tmp\work\pipeline_1_6dev
Email: rick.herrick@wustl.edu
Site name: XNAT
Site URL: http://nrg115.nrg.mir
SMTP server: mail.nrg.wustl.edu
:show UP-TO-DATE
:copyResources
FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture snapshot of output files for task 'copyResources' during up-to-date check.
See stacktrace for details.
> Failed to create MD5 hash for file D:\Tmp\work\pipeline_1_6dev\.gradle.2.1\taskArtifacts\cache.properties.lock.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 20.639 secs
Note that I’m running in a tmp folder here because I wanted to test this on a clean version of my code to make sure other gradle runs hadn’t possibly locked that file and then not relinquished the lock. This happens in every situation.
Turning on the stacktrace gives the following extra info (this is trimmed down: the full stacktrace and run info is on
org.gradle.api.UncheckedIOException: Failed to capture snapshot of output files for task 'copyResources' during up-to-date check.
See stacktrace for details.
at org.gradle.api.internal.changedetection.rules.TaskUpToDateState.<init>(TaskUpToDateState.java:50)
...
Caused by: org.gradle.api.UncheckedIOException: Failed to create MD5 hash for file D:\Tmp\work\pipeline_1_6dev\.gradle.2.1\taskArtifacts\cache.properties.lock.
at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:37)
... 44 more
Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:50)
at org.gradle.internal.hash.HashUtil.createHash(HashUtil.java:34)
... 59 more
As I said, this works on OSX, Centos, and Ubuntu. The failure is limited to Windows machines. I’ve tested it on three separate machines, all Windows 7 64-bit and gotten the same failure on each of them.
I’m reasonably certain this is a bug and I’ll happily file a bug report on it, but if there was a workaround I could use in the short term, that would be outstanding as well.
Thanks in advance!