Stopping Gradle daemon via Tooling API

(Marcin Zajączkowski) #1

In my plugin I use smoke testing to verify that at least base use cases work fine with Gradle 2.0 to 2.12. I use Nebula plugin and the Tooling API under the hood. Unfortunately daemons remain live after test execution allocating a few GBs of RAM which is not desirable especially on CI server.

A few years ago it was not possible to stop daemon using Tooling API. I wonder if it has changed in the meantime and if not what is the best way to handle it (I would like to have a daemon stopped after a test with given Gradle version)?

(Benjamin Muschko) #2

There’s no public API to stop daemons at the moment. We have some internal classes which you could look into e.g. DaemonLogsAnalyzer. It allows you to point to a daemon base directory (usually ~/.gradle/daemon/<version>) and kill the daemons with the method killAll().

(Attila Kelemen) #3

If it is for testing, you can set the daemon timeout to a low value. This is what I do when I’m running tests against multiple Gradle versions.

(Marcin Zajączkowski) #4

Thanks guys for your replies.

@bmuschko Killing daemon using OS command is one solution, but the class you mentioned pointed me to a static method ConnectorServices.reset(). It seems to work (stops daemon and allows to create a new connector from Nebula to another Gradle version), but it worries me a little bit that it is static and doesn’t operate just on a particular connector. Do you see any drawbacks of using it in functional tests?

@Attila_Kelemen Very smart idea to just tell a daemon to shut down after a moment. I like it.