2011-06-02 46 views
27

是否有任何可能使用本地Maven倉庫(〜/ .m2)作爲本地Ivy緩存(〜/ .ivy)?他們有不同的佈局。使用Maven倉庫作爲本地常春藤緩存

有時我使用Maven,有時候我使用SBT,它使用下面的Ivy,所以我在Maven和Ivy中都有2個相同的庫。我想使用相同的目錄,從而節省磁盤空間和網絡。

謝謝。

回答

22

爲了節省網絡,只是configure ivy to use local Maven repository

 <property name="local-maven2-dir" value="${user.home}/.m2/repository/" /> 
     <filesystem name="local-maven-2" m2compatible="true"> 
      <artifact 
       pattern="${local-maven2-dir}/[organisation]/[module]/[revision]/[module]-[revision].[ext]" /> 
      <ivy 
       pattern="${local-maven2-dir}/[organisation]/[module]/[revision]/[module]-[revision].pom" /> 
     </filesystem> 
0

我加入了文件下列文件中的緩存設置。這是正確的方法嗎? SBT仍在下載Maven本地回購(~/.m2/repository)中的文件。

$ cat ~/.ivy2/ivysettings.xml 
<ivysettings> 
    <properties environment="env" /> 
    <caches defaultCacheDir="${env.WORKSPACE}/.ivy2/cache" /> 

    <property name="local-maven2-dir" value="${user.home}/.m2/repository/" /> 
    <filesystem name="local-maven-2" m2compatible="true" force="false" local="true"> 
     <artifact pattern="${gerald.repo.dir}/[organisation]/[module]/[revision]/[module]-[revision].[ext]"/> 
     <ivy pattern="${gerald.repo.dir}/[organisation]/[module]/[revision]/[module]-[revision].pom"/> 
    </filesystem> 

    <chain name="internal" dual="true"> 
     <resolver ref="local-maven-2"/> 
     <resolver ref="apache-snapshot"/> 
     <resolver ref="maven2"/> 
    </chain> 
</ivysettings>