This PR fixes the scalacWorker so that it calls close() on the compiler object (nsc.Global) after each job is done. This allows file resources (i.e. dependent jar files, source files, etc) that the compiler uses to be properly released after each job.
Note that nsc.Global did not add the close() functionality until v2.12. This is handled in this PR.
Motivation
This issue was noticed more on Windows since Windows will lock the file (and not allow edits) until it is released. And with scalacWorker being a persistent process, it would lock the files until you called “bazel shutdown”.
This should resolve #1486, where this issue was causing *-ijar.jar handles not to be released.
Aside: There is still an issue where the jars for plugins are not being released (because calling nsc.Global.close() does not release the plugins). This is probably more of a Bazel core issue where Bazel needs to stop the workers when any plugins (or other tooling used by the worker) need to be recompiled. The related issue is Bazel issue #10498.
Description
This PR fixes the scalacWorker so that it calls close() on the compiler object (nsc.Global) after each job is done. This allows file resources (i.e. dependent jar files, source files, etc) that the compiler uses to be properly released after each job.
Note that nsc.Global did not add the close() functionality until v2.12. This is handled in this PR.
Motivation
This issue was noticed more on Windows since Windows will lock the file (and not allow edits) until it is released. And with scalacWorker being a persistent process, it would lock the files until you called “bazel shutdown”.
This should resolve #1486, where this issue was causing *-ijar.jar handles not to be released.
Aside: There is still an issue where the jars for plugins are not being released (because calling nsc.Global.close() does not release the plugins). This is probably more of a Bazel core issue where Bazel needs to stop the workers when any plugins (or other tooling used by the worker) need to be recompiled. The related issue is Bazel issue #10498.