I have a gradle project that needs some environment variable, however there’s some collision with existing environment variable for other projects, so I cannot set a global environment variable in the shell profile (like a $HOME/.zshrc).
It is possible to add a hook in zsh for example to perform these tasks, but it only works in the terminal. IntelliJ for example won’t see the update.
This can fail the project import because the variables are not yet set when IJ starts, or if set they will be plain wrong for the other project.
So I was wondering of init script had the ability to set/override an environment variable (depending on the project) ?
I fear I already know the answer as System does not offer a way to change environment variables after being started.
I was thinking there could a hidden API like casting to a specific type, or maybe a tooling API that could work around that. I didn’t found anything in IJ, but I recon I was lazy and didn’t check the gradle code base to ensure such API does not exists.
Unfortunately I’m not the owner of the project, and from I understand the software the project relies onto uses env vars.
I was looking for ways to isolate the settings for this project in particular with the current state of the code base.
Also are the gradle properties modifiable in the init scripts. (Writing on my phone so didn’t check the code yet).
Thank you for looking up the daemon bootstrap by the way.
No, unfortunately there is also no way to set project properties, let alone gradle properties (there is a slight difference, but you probably meant project properties), during runtime.
If the one reading it uses something like project.getProperty and similar, you can overwrite a project property by setting the according ext / extra property. But if the one reading the value for example uses providers.gradleProperty to read the project property, you cannot change the value at runtime.