Besides that your task does nothing at execution time, but always at configuration time and that always, even if the task will not run, it starts an executable with that environment variable set, but that has no effect whatsoever to the rest of the Gradle run, Gradle is not a shell command processor. Besides that the exec
should also not work at all but throw an exception as you didn’t specify an executable to execute.
If you want to set an environment variable on the test
task, then configure the test
task to set that environment variable.