UncheckedIOException: java.io.IOException when extracting file into root directory

Hello everyone,

I’m using Gradle 1.1 in Windows 7. I’m trying to create a task that extracts a tar.gz file into the root directory of the project but I get an exception when doing that: org.gradle.api.UncheckedIOException: java.io.IOException: The process cannot access the file because another process has locked a portion of the file

This is the task:

task untar (type: Copy) {
 from tarTree(resources.gzip('model.tar.gz'))
 into getProjectDir()
 }

I can’t figure out what I’m doing wrong. I have tried opening “cmd” and running the task just after the laptop is turned on and still the same result. Changing the destination to the regular build dir works just fine.

Thanks for all the help.

I was able to solve it using it like this:

task untar << {
    copy {
        from tarTree(resources.gzip('model.tar.gz'))
        into getProjectDir()
    }
}

My only guess is that either the dir or the tgz file or both are locked during the configuration phase and it’s released during the execution phase.

If someone has a solution using the copy task and not the copy method I would appreciate it.