Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven local repository location for Linux and Windows

Tags:

maven

I have a dual boot system with Windows and Linux. I have another partition which is visible to both Windows and Linux. I want to put my local repository there. How can I provide a path that both Linux and Windows will understand. Windows see it as d:/repository drive and Linux sees it as /media/234242342/repository. How should I configure this in pom.xml?

like image 203
user373201 Avatar asked Jul 31 '11 20:07

user373201


People also ask

Where is maven local repository Linux?

By default, Maven local repository is defaulted to ${user. home}/. m2/repository folder : Unix/Mac OS X – ~/.

Where is the maven local repository on Windows?

The Maven local repository is located in the /home/. m2 directory, the folder is probably hidden.


2 Answers

Each OS needs an M2_HOME as per the Maven documentation. Inside $M2_HOME/conf/ you can put a settings.xml file and in that you can specify the location for the local repository using the <localRepository/> element.

So for your specific system, in Windows use

<localRepository>d:\repository</localRepository> 

and in Linux

<localRepository>/media/234242342/repository</localRepository> 
like image 75
andyb Avatar answered Nov 04 '22 14:11

andyb


You don't do that in the POM, but in your ~/.m2/settings.xml, which would be different for both Linux and Windows, so no problem. See the localRepository element:

<settings>     <localRepository>d:\repository</localRepository>     <!-- or -->     <localRepository>/media/234242342/repository</localRepository>     ...  </settings> 
like image 23
Ryan Stewart Avatar answered Nov 04 '22 14:11

Ryan Stewart