Getting a live view of environment variables (Gradle and JDK 9)

Chris Hegarty chris.hegarty at
Tue May 16 19:29:23 UTC 2017

> On 16 May 2017, at 20:19, Mario Torre <neugens.limasoftware at> wrote:
> ..
> Regarding your example:
> """
> println System.getenv('MY_VAR')
> doesn't print "foo" after doing:
> MY_VAR=foo gradle printVar
> """
> I agree that the environment variables may change during the program
> execution and that perhaps Java may eventually need to reflect that,
> but this example is not really appropriate, the Java process started
> with an environment variable not set, the one that starts with
> MY_VAR=foo is technically a different process…

Sure, but the “daemon” ( in terms of Gradle ) should behave “as if” it were
the initiating process. I have some sympathy for this.

Re-reading/refreshing the env variables has come up before, in other
contexts. As David pointed out [1], re-reading introduces no more risk than
is already there ( if specified correctly ).



More information about the core-libs-dev mailing list