Setting org.gradle.daemon.idleTimeout through tooling API?

We build on our CI server with --no-daemon. However our tests use the tooling API to run other builds (we develop a plugin) and this starts daemons.

I’d like to make those daemons very short-lived. I’ve found references to org.gradle.daemon.idleTimeout but I just cannot inject it through the tooling API.

I’m trying to inject with in the BuilderLauncher (withArguments, setJvmArguments), I’m putting it in the of the test projects or my home folder, nothing works.

I’m trying to run tests in parallel which is going to start a dozen or more daemons and I don’t want them to stay around. How can I do this?


At the moment setting daemon idle time is only possible via an internal API. You have to utilise the fact that the instance returned from ‘GradleConnector.newConnector()’ is a ‘DefaultGradleConnector’:

GradleConnector connector = GradleConnector.newConnector();
((DefaultGradleConnector) connector).daemonMaxIdleTime(1, TimeUnit.SECONDS);

I think IntelliJ already does that when it is loading models but I am not sure how they do it.

Looking at the code it seems that ProviderConnection class sets DaemonParameters.idleTimeout property only when it is passed in connection parameters and AFAIK the only place where this can be set is

I suppose we should push this method to a public API of GradleConnector.

daemonMaxIdleTime work great, thanks!