Thursday, February 8, 2024

Import project configuration from a file in Intellij

When running maven project or any project in IntelliJ that depends on some credential and configuration it is very hard to provide it every time on the terminal using export. You can do it by either export or by putting it to bashrc or zshrc profile.
Here is an way where you can do it just by using a file and a plugin and this will be used only in the IntelliJ build and run.
To do that create a .env file using your all the export. Make sure not to add the export command. Only the assignment or declaration.


Example: report-server.env

 

DC="local_cluster"
SERVICE_NAME="NA"
ENVIRONMENT="dev"
SSL_KEY_STORE_PASSWORD="LAFSHTDBJIWQVHBHSHJD"
SERVER_MODE="MASTER"
REPORT_SERVER_HOST="localhost"

After that you need to install a plugin in the IntelliJ Idea. To do that, open IntelliJ and 

go to the Settings -> Plugins . On the popup window search box type "EnvFile" and install the EnvFile plugin.

                                                       Fig 1: IntelliJ Idea Plugin installation

 

After successful installation the IDE will need a restart.
Then just create the run configuration from the Run->Edit Configuration. 

It will open a window where you need to select your project target and runtime. 

For JAR project it should be the following,


                                                    Fig 2: Configuration with EnvFile


If the plugin installed successfully you will find the EnvFile tab there. Now from the EnvFile tab enable env file and add the location of your env file on the project.
Thats it!
Now every time you build or run it will take the configuration and environment param from this file.

No comments:

Post a Comment

How to enable hotspot in TPG iPhone

 By default, the hotspot does not work on the phone. It will ask you to contact the provider. This video will help you bypass the network ...