-1

I have been struggling to understand where Maven (version 3.1.1) looks for the local settings.xml file on Windows 7. Can someone please explain what Maven is doing as it logs the below lines during the execution of any mvn command with the -X switch?

[DEBUG] Reading user settings from ???

Is it examining an environment variable to construct the path? If so, which one? I'm asking this because I was greatly surprised to see that it was examining the path

\\computername\userName\.m2\settings.xml  

instead of the expected location on my C drive, which is

C:\Users\userName\.m2\settings.xml
JellyRaptor
  • 725
  • 1
  • 8
  • 20
  • https://maven.apache.org/settings.html – Tunaki Nov 08 '16 at 20:50
  • @Tunaki That documentation, which was the first place I looked, indicates that it should be looking at ${user.home}, which on Windows 7 should be %UserProfile%. When I echo that system variable, it shows the expected path on the C drive. Since that path is not the path Maven is using, that documentation is not helpful in answering this question. That is why I am asking asking for further clarification on SO. – JellyRaptor Nov 08 '16 at 21:01
  • Then this isn't a Maven issue, it relies strictly on `${user.home}` and that's where it looks, but a Java issue, or something is wrong on your PC, possibly registry, see [this](http://stackoverflow.com/questions/2134338/java-user-home-is-being-set-to-userprofile-and-not-being-resolved) and [this](http://stackoverflow.com/questions/16889940/on-windows-7-how-does-java-jvm-set-user-home-system-property). – Tunaki Nov 08 '16 at 21:07
  • echo %user.home% shows the correct, expected path, which is not the one Maven is using – JellyRaptor Nov 08 '16 at 21:17
  • 1
    `user.home` is a system property set by Java, as returned by [`System.getProperties()`](https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getProperties--). It is not something that is set on the OS through an environment variable. `echo %user.home%` on the Windows command line has no reason to return something other than `%user.home%`, and it it does, it isn't taken into account anyway. – Tunaki Nov 08 '16 at 21:20

1 Answers1

0

As Tunaki has pointed out, Maven uses the Java system property ${user.home}, which does not always resolve to path that we might expect it to.

To force ${user.home} to be a different path, I had to add the environment variable "_JAVA_OPTIONS" and give it the value "-Duser.home=%UserProfile%", which is the path I thought it should have been looking in the whole time.

JellyRaptor
  • 725
  • 1
  • 8
  • 20