Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ : executing a program with environment variables stored in a separated file

My application needs custom environment variables to run. I have created a run configuration in IntelliJ in order to start the application. For environment variables, I have set VM options.

Example :

-DDATABASE_URL=jdbc:oracle:thin:@dbbdevdb0397.fr:1522:DBZD08

My concern is to add all environment variables in my IntelliJ configuration automatically. That is why I have set these environment variables inside a separated file

Example : DEV.env

DATABASE_URL=jdbc:oracle:thin:@dbbdevdb0397.fr:1522:DBZD08

Is it possible to load this file DEV.env in a IntelliJ run configuration as it could be done by SH script:

eval $(cat DEV.env | sed 's/^/export /');
like image 962
OlivierTerrien Avatar asked Jul 12 '17 11:07

OlivierTerrien


1 Answers

As of March 14th 2017 it appears that someone has written a plugin which allows this.

Open settings, then select plugins In the search box search for “.env files support” and install it. After restarting IntelliJ you will have a new tab in the Run Configurations screen called EnvFile. The EnvFile tab will have a checkbox for enabling EnvFile support and a list where you can specify the env files you want to load prior to launching that specific run configuration; you need to set the env file option up for each run configuration.

I have a similar use case to yours and it works for me in specifying env files associated with a run configuration.

Additional Information on the plugin: https://plugins.jetbrains.com/plugin/7861-env-file

like image 144
Angelo Avatar answered Oct 14 '22 17:10

Angelo