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 W开发者_Go百科indows 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
?
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>
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>
You can run :
mvn help:evaluate -Dexpression=settings.localRepository
source
It is located in the /home/.m2 directory, the folder is probably hidden. So, you'll need to press Ctrl+H to see hidden folders.
Can't you just define both locations as separate repositories and let maven use the available one?
Or symlink /media/234242342/repository
to /repository
and use this path for both builds.
Also, have a look at maven profiles, it might be helpful!
If you are using CentOS version 7 the Maven local repository will be:
/root/.m2/repository/
Windows:
C:\Users<User_Name>.m2
Linux:
/home/<User_Name>/.m2
Mac:
/Users/<user_name>/.m2
And of course, for Linux and Mac, we can write in the short form:
~/.m2
精彩评论