Use maven repository as local ivy cache

喜欢而已 提交于 2019-12-03 03:37:58

问题


Is there any possibility to use local Maven repository (~/.m2) as local Ivy cache (~/.ivy)? They have different layouts.

Sometimes I use Maven and sometimes I use SBT which uses Ivy underneath, so I have 2 copies of same libs in both Maven and Ivy. I would like to use same dir thus saving disk space and network.

Thanks.


回答1:


You can specify the cache and the layout of the cache by using the

  <cache/> Tag

.

I think you will have to alter the patterns for the artifacts/ivy.xml files.
The Tag is described here: http://ant.apache.org/ivy/history/2.0.0/settings/caches.html.
It seems that it should work, but I've never tried :).




回答2:


To save network, just 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>



回答3:


I have added the cache setting in following file. Is this correct method? SBT is still downloading the files which are present in Maven local repo ( ~/.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>


来源:https://stackoverflow.com/questions/6216224/use-maven-repository-as-local-ivy-cache

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!