This message was deleted.
# community-support
s
This message was deleted.
d
You are probably falling into some of the weirdness of the GradleRunner API. I don’t remember exactly all the details but when the
withEnvironmen()
API is in use, internally Gradle has to fork a Gradle daemon to ensure the environment variable are properly configured. There are two things to be mindful here: 1) make sure you configure the project directory (https://docs.gradle.org/current/javadoc/org/gradle/testkit/runner/GradleRunner.html#withProjectDir-java.io.File-) and 2) you should always specify the working directory in your
ExecSpec
when it is important. In this case, you wish to run
chmod
in the
projectDir
so the
ExecSpec
should be configured as such:
Copy code
tasks.register('exec', Exec) {
  commandLine 'chmod'
  workingDir projectDir
}
a
Thanks Daniel! It seems withEnvironment() fully replaces the default System.getEnv(). I only need to add an extra one so I'm gonna try to combine the actual default environment with the few extra keys I need. The execSpec in question which is failing is an internal task managed by Gradle. The task which is failing is coming from the Application plugin. I'll take a peek and see if this task has anything I can configure or modify to get around this.
Finally got some time to test it out and it was an easy fix. Propagating the initial System.getEnv() into the map that I was adding with the .withEnvironment() method and adding my controlled key/value pairs after the fact, cleared it all up. My code was originally creating a map which contained only my controller key/value pairs.
d
Ah yes that is another gotcha with the Gradle Runner. A similar overwrite issue is also present with the withArgument(s) API.