IntelliJ Run Configuration: Load variable from .properties file before launch

拥有回忆 提交于 2019-12-13 21:54:24

问题


I have a .properties file that always contains the up-to-date IP address of the remote server where my application is running. So I wanna configure IntelliJ to read the IP from that file when I launch the remote debugging Run Configuration, instead of manually updating the Run Configuration every time the IP changes.

I tried creating an external tool that sets an environment variable like this:

export SUT_IP=$(cat /absolute/path/to/.properties | sed -rn 's/^SUT\.0\.IP=([0-9\.]*)/\1/p')

The extraction works well in a terminal window:

$ export SUT_IP=$(cat /absolute/path/to/.properties | sed -rn 's/^SUT\.0\.IP=([0-9\.]*)/\1/p')
$ echo $SUT_IP 
10.61.14.146

, but I get a error=2, No such file or directory if I add the external tool to "Before launch" in my remote debugging Run Configuration and run. In addition, I notice in the error message, the \1 in my sed command was changed to /1.

Apparently I was trying on a wrong direction. What is a recommended/common way of reading a variable when launching a Run Configuration in IntelliJ?

来源:https://stackoverflow.com/questions/45561379/intellij-run-configuration-load-variable-from-properties-file-before-launch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!