e.deandrea
(Eric Deandrea)
March 21, 2017, 12:25pm
1
We’re seeing a large number of directories being created by Gradle in our /tmp dir on our Jenkins servers:
drwxr-xr-x 3 wasmgr wasgroup 4096 Mar 17 07:00 gradle3653686569603919263projectDir
drwxr-xr-x 3 wasmgr wasgroup 4096 Mar 17 07:00 gradle3873120841179297595projectDir
drwxr-xr-x 3 wasmgr wasgroup 4096 Mar 17 07:00 gradle703379869211695195projectDir
drwxr-xr-x 3 wasmgr wasgroup 4096 Mar 17 07:00 gradle5252982363028816831projectDir
We’re not sure what plugin may be creating these, but it is causing our /tmp space to fill up rather fast.
This is likely due to the use of ProjectBuilder
. If you are using this in unit tests I suggest using a TemporaryFolder
JUnit rule (or similar) as the project directory so that these get cleaned up properly. If not, we create a temporary directory for you, and while we use File.deleteOnExit()
this in practice will only clean up the folder if it is empty.
e.deandrea
(Eric Deandrea)
March 21, 2017, 5:46pm
3
Thanks Mark - so something like this (what I was doing before didn’t have the .withProjectDir()
)?
@Rule
TemporaryFolder tempFolder
def getProject(String rootProjectName, String... childProjects) {
def projBuilder = ProjectBuilder.builder().withProjectDir(tempFolder.folder)
def root = projBuilder.withName(rootProjectName).build()
if (childProjects) {
childProjects.each {
def childProject = projBuilder.withName(it).withParent(root).build()
childProject.projectDir.mkdirs()
}
}
root
}
Yes, except you should be using tempFolder.root
.