Maven local repository location for Linux and Windows

后端 未结 6 1094
后悔当初
后悔当初 2021-02-02 09:26

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

相关标签:
6条回答
  • 2021-02-02 09:47

    If you are using CentOS version 7 the Maven local repository will be:

    /root/.m2/repository/
    
    0 讨论(0)
  • 2021-02-02 09:51

    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.

    0 讨论(0)
  • 2021-02-02 09:57

    You can run :

    mvn help:evaluate -Dexpression=settings.localRepository
    

    source

    0 讨论(0)
  • 2021-02-02 10:01

    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>
    
    0 讨论(0)
  • 2021-02-02 10:02

    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>
    
    0 讨论(0)
  • 2021-02-02 10:04

    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!

    0 讨论(0)
提交回复
热议问题