Reputation: 19655
My PATH
and JAVA_HOME
are defined in ~/.bashrc
.
However, when I launch Intellij from my Favorite icon and then launch a Maven Run Configuration, these variables are not thus defined. But if directly I run the same idea.sh
script that is run from the Favorites icon, then they are recognized.
My pom.xml
does some exec
, so having these environment variables is essential.
The setting for "Include System Environment Variables" is checked. (As a test, I previously defined env variable FOOBAR
-- we see it is missing here.) .
How can I make this happen automatically, even when I use the Favorites icon? The desktop
file is given below.
[Desktop Entry]
Version=1.0
Type=Application
Name=IntelliJ IDEA Ultimate Edition
Icon=/hdd/executables/idea-IU-191.6707.61/bin/idea.svg
Exec="/hdd/executables/idea-IU-191.6707.61/bin/idea.sh" %f
Comment=Capable and Ergonomic IDE for JVM
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-idea
Upvotes: 12
Views: 19044
Reputation: 76
Had a very similar issue and found this post. It helped me but the following information was missing:
Restart: When creating a new environment variable, you have to close/reopen IntelliJ so the new variable is available.
Command Line: When you want to use it on the maven command line, you can do something like:
mvn clean install -DyourVariableName=${YOUR_ENV_VARIABLE}
Upvotes: 1
Reputation: 432
In case your env variables are comming from a seperate key management tool like Hashicorp Vault, there is a maven plugin that allows fetchin your secrets and making them available in your maven build.
Like so you don't have to duplicate their declaration in intellij.
Please see my answere here
Upvotes: 0
Reputation: 25976
Build, Execution and Deployment -> Build Tools -> Maven -> Runner -> Environment
Environment Variables
text box.Include System Environment Variables
Upvotes: 17
Reputation: 567
First click on marked button on configuration window,
then, check 'Include system variables' check box
Upvotes: 3