Task initializing Gradle daemon doesn't terminate on Windows

I have a task that performs a couple of clean and copy tasks on Windows 8.1:

copyDestinations.each 
{ destination ->

  def cleanTaskName = "clean_$destination.name"
  def copyTaskName = "copy_$destination.name"
  task(cleanTaskName, type: Delete) {
    delete destination.location
  }

  task(copyTaskName, type: Copy) {
    dependsOn(cleanTaskName)
    from project.gradle.gradleUserHomeDir.getCanonicalPath() + '/../Artifact Dependencies'
    from configurations.talendLibs
    from fileTree('Executables/Conversion/ArtifactDependencies/')
    into destination.location
  }

  talendDependencies.dependsOn(copyTaskName)
}

When calling this task from a batch file with the daemon enabled, the daemon initializes and the task runs successfully, but the process doesn’t exit. This behavior is the same whether I’m running gradle 2.11, 2.14, or 3.0-m1, by way of the wrapper. Presumably it is waiting on the daemon and would exit in 3 hours when the daemon times out, because killing the process kills the daemon as well. This makes it impossible to use the task when scripting without using the --no-daemon flag because the script hangs waiting for that child.

Is this just a fundamental limitation on Windows, that you can’t really daemonize the way you can on Unix? If so this should be part of the documentation.

Thanks for reporting the problem.

This might be related to file locking on Windows. Do you have the chance to check if there is some process locking files in the directory that is being cleaned? You could use handle.exe from SysInternals to see active file handles.
There are some related issues in the Gradle jira, for example https://issues.gradle.org/browse/GRADLE-2275 . However I’m not sure if that is the issue in this case. Some improvements are in progress for Gradle 3.0 .