MAVEN_OPTS not set correctly when relocating Maven
Dev Home version
0.1501.533.0
Windows build number
No response
Other software
No response
Steps to reproduce the bug
Move m2 directory using Dev Home
Expected result
MAVEN_OPTS should be used to override parameters sent to the JVM. However, it's just set to the new m2 directory path. But the JVM of course does not know how to just handle a path stuck into its args.
Actual result
Doesn't work. JVM fails to launch.
Included System Information
No response
Included Extensions Information
No response
An example of how to use MAVEN_OPTS: set MAVEN_OPTS=-Duser.home=D:\home\userFoo\bin\maven.config.directory
However, Dev Home just sets it to D:\home\userFoo\bin, etc.
But I also think probably M2_HOME or MAVEN_HOME are the correct variables to be used.
M2_HOME or MAVEN_HOME
I don't think so. This should be the location of maven installation directory and it's not on Dev Drive.
Well, it's the location of the local Maven user directory. Which is usually not the install directory. It's where the settings.xml file would live. Which by default puts the local repository (cache) next to itself.
So, two options: move all the user settings to the location dev home describes (and use M2_HOME), or alter the settings.xml to change the path of the local repository. I do not think there is an env variable that specifically relocates the local repository, since it's described by the master settings.xml file.
Yeah, settings.xml describes the default expression for <localRepository> as ${user.home}/.m2/repository
So you'd have to actually edit the settings.xml.
The MAVEN_HOME environnement variable is used to configure where Maven is installed:
M2_HOMEwas for Maven 2, but it's been more than 10 years since Maven 3 is released, I believe we can ignore it- Installing Maven in Dev Drive might help to speed it up a bit, but that's not the most important setting to do.
The real issue for Dev Drive is to have the Maven repository cache in Dev Drive: this is where the librairies are stored, and that's where you'll gain from the extra I/O from Dev Drive.
By default this Maven repository cache is set up in ${user.home}/.m2/repository/, and to have it configured inside Dev Drive, the normal way would be to set it inside your ${user.home}/.m2/settings.xml configuration file (see https://maven.apache.org/guides/mini/guide-configuring-maven.html for full details).
Now what is being done here, with MAVEN_OPTS, is pretty smart: this is modifying the user's home directory for Maven, so that it points to Dev Drive. This would remove the need to modify the ${user.home}/.m2/settings.xml configuration file at the expense of creating this environment file, so I'm not sure it's worth it.
My recommendation would be to:
- (Optional) Install Maven on Dev Drive, and point to it with the
MAVEN_HOMEenvironment variable - (Recommended) Modify the
${user.home}/.m2/settings.xmlconfiguration file to point to Dev Drive, for example<localRepository>D://maven-repository</localRepository>