在團隊開發中,讓所有開發人員直接存取公共 Maven 儲存庫並非最佳實踐:
Ivy 的 install 任務正是為了解決這些問題而設計。它允許你建立一個專門的「儲存庫維護建構」,配置指向外部來源(如 Maven Central),然後透過簡單的命令列指令,將所需模組(連同其依賴)批量複製到團隊內部儲存庫。
範例專案位於 src/example/build-a-ivy-repository,包含一個 Ant 建構檔與數個 Ivy 設定檔。執行 ant -p 可見主要 target:
Buildfile: build.xml
Main targets:
clean-cache --> clean the cache
clean-repo --> clean the destination repository
maven2 --> install module from maven 2 repository
maven2-deps --> install module from maven 2 repository with dependencies
maven2-namespace --> install module from maven 2 using namespaces
maven2-namespace-deps --> install module with dependencies from maven2 repo using namespaces
Default target: basic
這些 target 分別對應無依賴安裝、傳遞依賴安裝、以及使用命名空間的進階安裝場景。接下來的教程將逐一深入講解。