Gradle daemon causing issues with plugin execution


I wrote a plugin for internal consumption. It is a plugin for integrating with Jenkins and executing / configuring jobs. In short, the plugin does the following,

  • Create the extension on the project.
  • In the target.afterEvaluate { // read some configuration files and then create additional tasks }
  • During the task execution, the plugin might want to acquire user input - So I get hold of System.console and, if available, acquire the user input.

After upgrading to 3.1, I noticed a few issues,

Inconsistent errors / failures

  • IllegalStateException: Cannot locate service of type DependencyMetaDataProvider, as ProjectScopeServices has been closed.
  • System.console is null - which makes sense if the process is running on the daemon, but doesn’t help my case.

But, when I explicitly disable the daemon (via command line) it works perfectly fine.

Here is a sample stacktrace for issue 1

Caused by: java.lang.IllegalStateException: Cannot locate service of type DependencyMetaDataProvider, as ProjectScopeServices has been closed.
at org.gradle.internal.service.DefaultServiceRegistry.doGet(
at org.gradle.internal.service.DefaultServiceRegistry.get(
at org.gradle.api.internal.project.DefaultProject.getModule(
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.getProperties(
at org.gradle.internal.metaobject.BeanDynamicObject.getProperties(
at org.gradle.internal.metaobject.CompositeDynamicObject.getProperties(
at org.gradle.api.internal.project.DefaultProject$4.create(
at org.gradle.api.internal.project.DefaultProject$4.create(
at org.gradle.util.SingleMessageLogger.whileDisabled(
at org.gradle.api.internal.project.DefaultProject.getProperties(
at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.getProperty(
at org.gradle.internal.metaobject.BeanDynamicObject.getProperty(
at org.gradle.internal.metaobject.CompositeDynamicObject.getProperty(
at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(
at org.gradle.api.internal.project.DefaultProject_Decorated.getProperty(Unknown Source)

So, I would like to know if there are any FAQs / Guidelines for developer to verify that their plugin would work well against the new version?

What is the preferred way for a Gradle plugin to acquire user input? The execution environment of the plugin can be controlled, so I can make a few changes to it. For example, if there is a way to identify that the plugin code is being executed in the daemon, I can provide a warning / update the user’s property file and inform them to run it again.

Looking forward to your responses.


1 Like