I'm using Maven, and it stores local repository under user home folder.
I decided to move my user profile from C:\\Users\\Dany
to D:\\Users\\Dany
to save my SSD disk space. Also I changed several keys in windows registry.
All works fine but Maven still save artifacts to C:\\Users\\Dany\\.m2\\repository
.
I know how to change local repository location in settings.xml
.
But could somebody explain Maven's behaviour?
PS
IntelliJ IDEA also saves its data to C:\\Users\\Dany\\.IntelliJIdea11
.
UPD
System.getProperty("user.home");
returns C:\\Users\\Dany
.
UPD2
set USERPROFILE
in windows comand line says USERPROFILE=D:\\Users\\Dany
.
UPD3
Question is about how Java gets user home folder location but not about how to set Maven repository location
On Windows Java gets the user.home property from the registry: HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Desktop then it removes the last folder.
For example: %userprofile%\\Desktop => %userprofile%
This is (will be) fixed in Java 8.
Until then, the solution is to add this into the environment variables:
_JAVA_OPTIONS:-Duser.home=%HOMEDRIVE%%HOMEPATH%
or in command line: set _JAVA_OPTIONS=-Duser.home=%HOMEDRIVE%%HOMEPATH%
I saw the solution in the comments of this page: http://www.timehat.com/javas-user-home-is-wrong-on-windows/
Put a settings.xml file into D:\\Users\\Dany.m2\\ and put something like this into your settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:/WhatEverLocationYouWant</localRepository
</settings>
First, you need to update the <localRepository> setting in the settings.xml in your home folder.
Next, you need to update the M2_REPO environmental variable to point to the new location. You may also need to set it for individual Eclipse projects , either by using maven itself or setting the environmental variable from the Eclipse settings.
If you have NTFS on both partitions, you could just create a symlink from D:\\Users\\Dany to C:\\Users\\Dany. Software won't see any difference.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.