Is there any option to set a map of environment va...
# community-support
p
Is there any option to set a map of environment variables for a Test task lazily based on a task output (except waiting for the postponed lazy provider migration)?
n
you could write the variables to a file and configure a
doFirst
action on your test task that reads the file and configures the env variables?
a
Does it need to be an environment variable? With
getJvmArgumentProviders()
system properties can be passed in lazily (using
listOf("-DpropName=propValue")
. https://github.com/gradle/gradle/blob/v9.2.1/subprojects/core-api/src/main/java/org/gradle/process/JavaForkOptions.java#L168-L175
l
Just use
val_name = providers.environmentVariable("ENV_VAL_NAME")
Misread it, you want to set the variable. Adam's point about
jvmArgumentProviders
is likely the cleanest way if your app can use System Properties.