天天看点

ivy 配置 maven代理

Ivy 是一个依赖管理工具,直观感受是其跟maven 的作用差不多;但这两个其实是不同的工具:

maven 是面向整个项目的工程管理及构建工具;

ivy 仅作为依赖管理工具,与ant 高度集成。

需要了解更多不同,可看看这里:

http://ant.apache.org/ivy/m2comparison.html

几年前了解到这东西,也是因为 play! 框架内置的依赖使用它进行依赖管理,但至今国内仍然以maven 作为主流依赖管理工具,看来还是先入为主的问题。

项目尽管使用了 ivy,依赖的处理仍然会选择 maven2 兼容仓库ibiblio,也是国外的站点。

众所周知的原因,国外站点的资源下载是龟速的,有必要给它提提速了。

修改 ${USER_HOME}/.ivy2/ivysettings.xml

<ivy-settings>
<!-- path to local maven repo and default maven layout -->
<property name="local-maven2-pattern"
value="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision]"
override="false" />
 
<!-- set resolver chain as default -->
<settings defaultResolver="main" />
 
<!-- configure caches -->
<caches repositoryCacheDir="${user.home}/.ivy2/cache">
<!-- do not cache from local .m2-->
<cache name="nocache" useOrigin="true" />
<cache name="default" />
</caches>
 
<resolvers>
<chain name="main">
<!-- as this is not cached, even changing SNAPSHOT dependencies
are resolved correctly -->
<filesystem name="local-maven-2" m2compatible="true" local="true"
cache="nocache">
<ivy pattern="${local-maven2-pattern}.pom" />
        <artifact pattern="${local-maven2-pattern}(-[classifier]).[ext]" />
</filesystem>
<!-- use repository manager as proxy to maven-central
(and all other repositories)-->
<ibiblio name="repomanager" m2compatible="true"
root="http://maven.aliyun.com/nexus/content/groups/public/" cache="default"/>
</chain>
</resolvers>
</ivy-settings>      

解释 

resolvers 配置了 名为main 的依赖处理链,包括两个处理器:

1 本地文件系统,用于兼容 maven2 的路径

如果 已经存在maven项目且下载了依赖包,会从maven 本地 repo目录中获取,不缓存到 ivy目录

2 ibiblio ,兼容maven 的处理器

使用阿里云的 镜像地址(仓库地址),默认缓存到 ivy 目录

ivy 配置 maven代理

作者:

zale

出处:

http://www.cnblogs.com/littleatp/

, 如果喜欢我的文章,请

关注我的公众号

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出

原文链接

 如有问题, 可留言咨询.