If you need to set some environment variables for all tasks of the project, then you could skip configuring tasks.json and use direnv. Using this tool to set project-specific environment variables is mentioned in Gradle for Java - Visual Studio Code.