Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAVEN_OPTS not set correctly when relocating Maven #3336

Open
wasabii opened this issue Jun 29, 2024 · 7 comments
Open

MAVEN_OPTS not set correctly when relocating Maven #3336

wasabii opened this issue Jun 29, 2024 · 7 comments
Assignees
Labels
Area-DevDriveInsights Good-First-Issue Good for newcomers Issue-Bug Something isn't working or needs investigation Priority-2

Comments

@wasabii
Copy link

wasabii commented Jun 29, 2024

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

@wasabii wasabii added the Issue-Bug Something isn't working or needs investigation label Jun 29, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage New issue that the core contributors need to triage label Jun 29, 2024
@wasabii
Copy link
Author

wasabii commented Jun 29, 2024

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.

@wasabii
Copy link
Author

wasabii commented Jun 29, 2024

But I also think probably M2_HOME or MAVEN_HOME are the correct variables to be used.

@SohamDas2021 SohamDas2021 self-assigned this Jul 8, 2024
@SohamDas2021 SohamDas2021 removed the Needs-Triage New issue that the core contributors need to triage label Jul 8, 2024
@btueffers btueffers added the Good-First-Issue Good for newcomers label Jul 22, 2024
@xuanswe
Copy link

xuanswe commented Aug 22, 2024

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.

@wasabii
Copy link
Author

wasabii commented Aug 27, 2024

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.

@wasabii
Copy link
Author

wasabii commented Aug 27, 2024

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.

@wasabii
Copy link
Author

wasabii commented Aug 27, 2024

Yeah, settings.xml describes the default expression for as ${user.home}/.m2/repository

So you'd have to actually edit the settings.xml.

@jdubois
Copy link

jdubois commented Sep 23, 2024

The MAVEN_HOME environnement variable is used to configure where Maven is installed:

  • M2_HOME was 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_HOME environment variable
  • (Recommended) Modify the ${user.home}/.m2/settings.xml configuration file to point to Dev Drive, for example <localRepository>D://maven-repository</localRepository>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-DevDriveInsights Good-First-Issue Good for newcomers Issue-Bug Something isn't working or needs investigation Priority-2
Projects
None yet
Development

No branches or pull requests

7 participants