Search code examples
maven

How to specify an alternate location for the .m2 folder or settings.xml permanently?


I am using Maven 3.0, and my .m2 folder location is C:\Users\me\.m2.

However, I do not have write access to that folder, but I want to change the repository location from the one defined in the settings.xml.

Due to restricted access, I am not able to edit the settings.xml to change the repository location.

How can I override the values of my settings.xml -or change the default location of the .m2 folder- without editing my C:\Users\me\.m2\conf\settings.xml file?


Solution

  • You need to add this line into your settings.xml (or uncomment if it's already there).

    <localRepository>C:\Users\me\.m2\repo</localRepository>
    

    Also it's possible to run your commands with mvn clean install -gs C:\Users\me\.m2\settings.xml - this parameter will force maven to use different settings.xml then the default one (which is in $HOME/.m2/settings.xml)