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

作者:
zale出處:
http://www.cnblogs.com/littleatp/, 如果喜歡我的文章,請
關注我的公衆号本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出
原文連結如有問題, 可留言咨詢.