The gradle jar tasks hangs, creating an infinitely-growing jar file without terminating

I have a project setup with one parent projects with several subprojects. One of these subprojects (let’s call it project E) references most of the other subprojects as a dependency. Using the Java Plugin, I try to run the jar task on project E, but the jar task never terminates and creates an ever-growing jar file in my E/classes/libs folder.

I’ve encountered this error using milestone 5 and 7. When I run in debug mode the last few lines of output are:

09:30:42.976 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ‘:E:compileJava’ 09:30:42.976 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :E:processResources 09:30:42.976 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ‘:E:processResources’ 09:30:42.977 [INFO] [org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter] Skipping task ‘:E:processResources’ as it has no source files. 09:30:42.977 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ‘:E:processResources’ 09:30:42.977 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :E:processResources UP-TO-DATE 09:30:42.977 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :E:classes 09:30:42.977 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ‘:E:classes’ 09:30:42.978 [INFO] [org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter] Skipping task ‘:E:classes’ as it has no actions. 09:30:42.978 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ‘:E:classes’ 09:30:42.978 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :E:jar 09:30:42.978 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ‘:E:jar’ 09:30:42.982 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ‘:E:jar’ is up-to-date 09:30:42.985 [DEBUG] [org.gradle.api.internal.changedetection.DefaultFileCacheListener] Can cache files for file tree 09:30:42.985 [DEBUG] [org.gradle.api.internal.changedetection.DefaultFileCacheListener] Can cache files for directory ‘C:\workspace\mainstream\E\classes’ 09:30:42.985 [DEBUG] [org.gradle.api.internal.changedetection.DefaultFileCacheListener] Can cache files for file ‘C:\workspace\mainstream\E\classes\libs\E-1.0.jar’ 09:30:43.005 [INFO] [org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository] Executing task ‘:E:jar’ due to: Output file C:\workspace\mainstream\E\classes\libs\E-1.0.jar for task ‘:E:jar’ has changed. Output file C:\workspace\mainstream\E\classes\libs\E-1.0.jar has been removed for task ‘:E:jar’. 09:30:43.005 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] task ‘:E:jar’ is not up-to-date 09:30:43.006 [DEBUG] [org.gradle.api.internal.changedetection.DefaultFileCacheListener] Invalidate cached files for file ‘C:\workspace\mainstream\E\classes\libs\E-1.0.jar’ 09:30:43.006 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache taskArtifacts.bin (C:\workspace\mainstream.gradle\1.0-milestone-7\taskArtifacts\taskArtifacts.bin) 09:30:43.006 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache outputFileStates.bin (C:\workspace\mainstream.gradle\1.0-milestone-7\taskArtifacts\outputFileStates.bin) 09:30:43.007 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshots.bin (C:\workspace\mainstream.gradle\1.0-milestone-7\taskArtifacts\fileSnapshots.bin) 09:30:43.007 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileHashes.bin (C:\workspace\mainstream.gradle\1.0-milestone-7\taskArtifacts\fileHashes.bin) 09:30:43.007 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on task artifact state cache (C:\workspace\mainstream.gradle\1.0-milestone-7\taskArtifacts). 09:30:43.008 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ‘:E:jar’. HANGS HERE********

I haven’t heard of this before. Can you attach a (small) build that allows us to reproduce the problem?

I’ve been trying to replicate this using a dummy code base (the error I’m seeing is in my company’s large and proprietary codebase), the setup is basically one large parent project with several subprojects. The subproject incurring this error includes all of the other subprojects as dependencies. I’ll keep trying to replicate.

For anyone else encountering this issue, a quick workaround is to generate a pom file for the project and create/install the jar using maven.

I am now seeing this issue when trying to generate javadoc for my entire project and all of its children projects. The javadoc task has a dependency on the jar task, and after running several times I’ve seen the jar task build an infinitely-growing jar for different subprojects each time. Seems to be a memory leak of some sort. I’ve tried in vain to build various versions of gradle on windows but have encountered build errors with each version, I intend to try building gradle on linux and debugging from there. Any other debugging advice would be most welcome. Thanks.

How do you build the project, and how exactly does it fail? Our build server continuously builds the project on Windows, and apart from failing tests every now and then, there aren’t any known problems.

We ran into this issue as well. Here’s the debug log: It’s 21k lines long, but scrolling to the end you can see that “Executing actions for task ‘:artifactory-java-client-ning-services:javadocJar’.” took more than an hour, and the last line “Releasing lock on artifact cache (C:\Users\user.gradle\caches\modules-2).” was stuck for hour and a half before we killed it.

Hope the log helps!