Gradle daemon holds a lock on a jar dependency referenced via fileTree

issue-resolved
gradle-2275

(Lance Java) #1

Gradle Version / Operating System:

Build time:   2016-06-14 07:16:37 UTC
Revision:     cba5fea19f1e0c6a00cc904828a6ec4e11739abc
Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.7.0_21 (Oracle Corporation 23.21-b01)
OS:           Windows 7 6.1 amd64

Is this a regression? Unsure

I have two separate projects, projectA is building a jar, projectB is referenceing the jar via

dependencies {
   compile fileTree('c:/path/to/projectA/build/libs').matching {
      include '*.jar'
   }
}

It seems the gradle daemon is holding a lock on the jar file until I kill it

  1. Build projectA
  2. Build projectB
  3. Attempt to clean projectA
  4. Get the following error message
* What went wrong:
Execution failed for task ':clean'.
> Unable to delete file: c:/path/to/projectA/build/libs/projectA-x.y.z.jar

When I run gradle --stop I’m then able to clean projectA


(Michael Barnathan) #2

Thanks for posting this! We’ve filed GRADLE-2275 to track dependency locking issues with the daemon on Windows and will test the solution we’re developing against the case you’ve raised! We should have a fix soon.


(Stefan Wolf) #3

Hi,

this should have been already resolved in Gradle 3.0. Could you try that out?

Regards,
Stefan


(Lance Java) #4

Hi, unfortunately I don’t have the original source that caused this issue. I’ve just tested with another similar project setup and it works in 3.0 so I’m confident this has been fixed.

Thanks


(guai) #5

Gradle 3.1. Not sure if my jars are locked by fileTree as described, but locks are still here. I can not clean the project unless I exorcise the daemon.


(Marco) #6

actually with gradle-3.1 clean is broken for me entirely on windows, with or without daemon.
The affected jar can be deleted manually when no gradle process is running.

C:\Users\n3\Projects\leoz>gradlew.bat --stop
No Gradle daemons are running.
C:\Users\n3\Projects\leoz>gradlew.bat --no-daemon clean
Constructor DefaultSourceDirectorySet(String, FileResolver) has been deprecated and is scheduled to be removed in Gradle 4.0
:buildSrc:syncClasses UP-TO-DATE
:buildSrc:compileKotlin UP-TO-DATE
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestKotlin UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE
:leoz-boot:clean UP-TO-DATE
:leoz-central:clean UP-TO-DATE
:leoz-central-schema:clean UP-TO-DATE
:leoz-node:flywayClean
:leoz-node:jpaClean
:leoz-node:clean
:leoz-ui:clean UP-TO-DATE
:libs:clean UP-TO-DATE
:libs:barbarywatchservice:clean FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libs:barbarywatchservice:clean'.
> Unable to delete file: C:\Users\n3\Projects\leoz\libs\barbarywatchservice\build\libs\barbarywatchservice-2.0-SNAPSHOT.jar

* 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: 9.115 secs

C:\Users\n3\Projects\leoz>del C:\Users\n3\Projects\leoz\libs\barbarywatchservice\build\libs\barbarywatchservice-2.0-SNAPSHOT.jar
C:\Users\n3\Projects\leoz>