2

Let's say I would like to point to the Maven home via environmental variable, rather than enetering the actual path. When I use "$env.M2_HOME$" in mavenVersion.xml Idea seems to get it when loading the file:

<application>
  <component name="MavenVersion" mavenHome="$env.M2_HOME$" />
</application>

I can see the expanded value in Build, Execution, Deployment -> Build Tools -> Maven -> Maven home directory.

...but whenever Idea decides to save its settings it does so in their expanded form:

<application>
  <component name="MavenVersion" mavenHome="C:/apache-maven-3.3.9" />
</application>

I was thinking maybe one could make use of Appearance & Behavior -> Path Variables but Idea does not appear to allow entering anything but actual directory/path in Build, Execution, Deployment -> Build Tools -> Maven -> Maven home directory.

Am I out of luck here?

Jaroslav Záruba
  • 1,138
  • 5
  • 17
  • 27

1 Answers1

2

Answered here: https://stackoverflow.com/a/44758883/224239

In a nutshell: Define a Path Variable (e.g. MAVEN_HOME) with value matching your Maven home directory. When saving your project or general settings Idea will replace the value of Maven home directory with its respective variable placeholder...
...mavenVersion.xml will then look like this:

<application>
  <component name="MavenVersion" mavenHome="$MAVEN_HOME$" />
</application>

When using together with Settings Repository make sure to add _windows/path.macros.xml to your <userhome>/.IntelliJIdea<version>/config/settingsRepository/repository/.gitignore so you don't share machine-specific Path Variables across all your machines.

Jaroslav Záruba
  • 1,138
  • 5
  • 17
  • 27