ivy 配置 maven代理

Ivy 是一個依賴管理工具,直觀感覺是其跟maven 的做用差很少;但這兩個實際上是不一樣的工具:html

maven 是面向整個項目的工程管理及構建工具;
ivy 僅做爲依賴管理工具,與ant 高度集成。apache

須要瞭解更多不一樣,可看看這裏:
http://ant.apache.org/ivy/m2comparison.html緩存

 

幾年前瞭解到這東西,也是由於 play! 框架內置的依賴使用它進行依賴管理,但至今國內仍然以maven 做爲主流依賴管理工具,看來仍是先入爲主的問題。
項目儘管使用了 ivy,依賴的處理仍然會選擇 maven2 兼容倉庫ibiblio,也是國外的站點。
衆所周知的緣由,國外站點的資源下載是龜速的,有必要給它提提速了。框架

 

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

<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 目錄ide

相關文章
相關標籤/搜索