IntelliJ IDEA not resolving %USERPROFILE% variable

Answered

I have a Maven Java project, where I use the 'Maven Projects' menu to compile and deploy the artifacts. This usually works fine, but sometimes I get a problem.

Working situation:

The command generates something like this when I use 'deploy' option:

"C:\Program Files\Java\jdk1.8.0_45\bin\java" -Dmaven.multiModuleProjectDirectory=C:\MyProject -Djavax.net.ssl.trustStore=C:\Users\xyz\cacerts\java.cacerts ........ deploy

Notice that the javax.net.ssl.trustStore has an absolute path to my cacerts file, which is why my project successfully connects with the Nexus on its 'https' URL and it uploads artifacts correctly.

Above value '-Djavax.net.ssl.trustStore=C:\Users\xyz\cacerts\java.cacerts' gets picked from the MAVEN_OPTS environment variable.

Problematic situation:

The value I have stored in the MAVEN_OPTS is this: -Djavax.net.ssl.trustStore=%USERPROFILE%\cacerts\java.cacerts. Sometimes IntelliJ resolved the value %USERPROFILE% to C:\Users\xyz, where xyz is my username. However, in some cases, IntelliJ is not able to resolve this variable to absolute path, and hence it generates the deploy command like this:

"C:\Program Files\Java\jdk1.8.0_45\bin\java" -Dmaven.multiModuleProjectDirectory=C:\MyProject -Djavax.net.ssl.trustStore=%USERPROFILE%\cacerts\java.cacerts ........ deploy

Notice that the %USERPROFILE% is printed as it is. Hence, the deployment of artifacts eventually fails since absolute path is not known to IntelliJ.

Things I have tried:

I have tried restarting IntelliJ by invalidating cache, but it doesn't help. If I set the absolute path in the MAVEN_OPTS, then it works fine. However, after changing it back to %USERPROFILE%, it stops working after some time. If I use the command 'echo %USERPROFILE%' in command prompt, it prints correct path C:\Users\xyz all the time, regardless of whether it's working in IntelliJ or not.

Question:

Any suggestions why this is randomly happening and how to address it? How does IntelliJ exactly resolve such system/user environment variables?

0
1 comment

Please file a bug at https://youtrack.jetbrains.com/issues/IDEA with the logs attached (https://intellij-support.jetbrains.com/hc/articles/207241085) and the small sample project to reproduce.

0

Please sign in to leave a comment.