Check daemon activation programmatically [solved]

Hi, for my plugin I need to check whether the daemon is running or not. Currently I use this approach:

 DAEMON_PROP = 'org.gradle.daemon'
(project.hasProperty(DAEMON_PROP) && == 'true')

But this condition remains true when sets org.gradle.daemon to true and the user uses --no-daemon. Is there a more reliable way that takes into account the --no-daemon option?

EDIT: The startParameter class does not seem to capture the --no-daemon option:

EDIT: Rephrasing the same question: How can I check whether the user has activated the daemon using --daemon?

I suspect you’re wanting to check for the daemon because you’re using System.console?

There’s not a reliable way to tell if you’re in the daemon or not. If you’re trying to read from the console, I think you can get by with checking System.console() != null.