No, -Dorg.gradle.daemon=false is the correct property to control the build environment configuration. The build environment can be configured with gradle.properties, system properties (-D), or --daemon / --no-daemon options.
It is the case that build environment properties specified in gradle.properties will also show up as project properties, but just specifying a project property with -P will not configure the build environment.
The --daemon / --no-daemon options are the highest precedence way of configuring the build environment. They are not an alternate way to set the build environment property, so you wouldn’t see the equivalent build environment property exposed as a project property.
Thanks for the reply. It make sense for all, except the ‘-P’ vs ‘-D’:
My understanding is:
in gradle.profile key=value can be override with -Pkey=valuenot-Dkey=value.
Here are there outputs for
logger.quiet "System.properties['org.gradle.daemon'] is: ${System.properties['org.gradle.daemon']}"
logger.quiet "project.properties['org.gradle.daemon'] is : ${project.properties['org.gradle.daemon']}"
inside gradle.properties, set org.gradle.daemon=false
command line -Porg.gradle.daemon=false
command line -Dorg.gradle.daemon=false
outputs for case 1 and 2 are the same:
System.properties['org.gradle.daemon'] is: null
project.properties['org.gradle.daemon'] is : false
output for case 3 is different as expected:
System.properties[‘org.gradle.daemon’] is: false
project.properties[‘org.gradle.daemon’] is : null
So, why -D is correct not -P to match setting value inside gradle.properteis. Maybe org.gradle.daemon is just a special case?
Moreover, Is there someway to verify if the daemon is on or off?
Consider that there are two different things here: build environment configuration and properties available in the build. The build environment configuration is configured as listed in Build Environment Configuration Properties (project gradle.properties, user gradle.properties, system properties). This has to happen very early to setup the environment which later build setup occurs in and it simply doesn’t look at project properties (but considers gradle.properties as generic potential build environment properties). Yes, the build environment configuration properties set in gradle.properties show up as project properties too, but consider this just a side effect. It’s not what is controlling whether the daemon is really enabled.
A build scan or correlating gradle --status output are your easiest options. A stack trace is also doable, but more difficult in that you need to understand the internals.
This works if the environment variable is correctly set. It won’t be overwritten if you have only copied the gradle.properties and build.gradle contents to your project and run the command provided. You must do the equivalent for your OS to set the appropriate environment variable: