This is something that is not well documented on the web, though it is quite clearly in the default settings.xml file provided with the default Maven installation.
The default repository used by Maven 2 to store the various artifacts is <user_home>/.m2/repository. Under Windows, that translates to C:\Documents and Settings\<user>\.m2\repository.
On my client site, the size of the user home directory is severely restricted, presumably because it is being backed up. So, how do you change this value? Easy, once you know.
You need to have a settings.xml file, either in the <user_home>/.m2 directory, or in the <maven installation>/conf directory (make sure you keep a copy of the existing one). Add a new <localrepository> tag. On my machine, it looks like that:
<settings>... <localrepository>D:/mavenrepository</localrepository> <!-- any type of slashes works --> ... </settings>
That’s it!
Thanks a ton. I was looking for this information for quite some time. You saved my day.
Thank you, very helpful.
Also at least in maven 2.0.9 its
D:\mavenrepository
notice the capitol R in repository
Lol alright well its
>localRepository<C:\Tools\mavenRepo\repository<//localRepository>
Sweet; just what I was looking for. :)
Pingback: Ernesto’s Miscellanea » Blog Archive » Maven tips
At least I found this info. Thanks!
Thanks for the tip, Eric!
If you do not want to change your settings.xml, you can simply pass ‘-Dmaven.repo.local=’ to your mvn call
Hi! I am trying to change my local repository of maven, but I am using ant too, so I can’t find where to do it: in the fetch.xml (from ant) file, or in the settings.xml file. Of course i tried it changing the settings.xml, but it didn’t work, so now i am trying it in the fetch.xml and get-m2.xml of ant, but i haven’t got nothing yet…
any idea??????
thanx!!!!!
@sunes What you are trying to do is not clear to me… are you trying to have a common classpath for Maven and for Ant scripts embedded in Maven? I think you can obtain the classpath for the compile scope, though I’m not sure how.
If you have both Maven and (separate) Ant scripts, I guess you need to point to the Maven repository in two places.
Over 2 years later, your post is still helping people. Thanks for taking the time to post this tip!
It’s with a capital “R” http://maven.apache.org/ref/2.0.8/maven-settings/settings.html
Tranks a lot!
Thank you!
Thanks a lot!
Right the tip im searching for.
Thanks for that! You’re right, I was also looking for this on the Maven2 project user guide at http://maven.apache.org/guides/ and couldn’t find it..doesn’t seem to be there. This post came in handy! Cheers