使用maven存储库作为本地常春藤缓存

时间:2011-06-02 14:54:12

标签: maven-2 ivy

是否有可能使用本地Maven存储库(〜/ .m2)作为本地常春藤缓存(〜/ .ivy)?它们有不同的布局。

有时候我会使用Maven,有时我会使用下面使用Ivy的SBT,所以我在Maven和Ivy中都有2个相同的lib副本。我想使用相同的目录,从而节省磁盘空间和网络。

感谢。

3 个答案:

答案 0 :(得分:24)

要保存网络,只需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>

答案 1 :(得分:5)

您可以使用

指定缓存和缓存的布局
  <cache/> Tag

我认为你必须改变artifacts / ivy.xml文件的模式 标签在这里描述: http://ant.apache.org/ivy/history/2.0.0/settings/caches.html
它似乎应该有效,但我从未尝试过:)。

答案 2 :(得分: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>
相关问题