问题
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