Ivy 有時需要設定才能如預期工作。實際上 Ivy 可在完全無特殊設定下運作(參閱預設設定文檔),但透過正確配置可在完全不同情境下工作。設定透過 XML 檔案指定,通常命名為 ivysettings.xml。在 Ant 中配置 Ivy,只需用設定檔路徑使用配置資料類型。
<ivysettings>
<properties file="${ivy.settings.dir}/ivysettings-file.properties" />
<settings defaultCache="${cache.dir}" defaultResolver="ibiblio" checkUpToDate="false" />
<resolvers>
<ibiblio name="ibiblio" />
<filesystem name="internal">
<ivy pattern="${repository.dir}/[module]/ivy-[revision].xml" />
<artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]" />
</filesystem>
</resolvers>
<modules>
<module organisation="jayasoft" name=".*" resolver="internal" />
</modules>
</ivysettings>
大體上,設定檔配置 Ivy 使用的預設快取目錄和解析依賴的依賴解析器。
注意:此範例需要同目錄下的 ivysettings-file.properties 屬性檔提供所需 Ivy 變數。
1.4 版後,主要所有 Java 系統屬性皆可作為 Ivy 變數在設定檔中使用。
ivysettings
property
properties
settings
include
classpath
typedef
credentials
lock-strategies
caches
cache
latest-strategies
version-matchers
triggers
parsers
conflict-managers
outputters
namespaces
namespace
rule
fromsystem
src
dest
tosystem
src
dest
macrodef
attribute
any resolver
resolvers
any resolver
modules
module
statuses
status
每個設定檔的根標籤。
| 元素 | 描述 | 基數 |
|---|---|---|
| property | 設定 Ivy 變數 | 0..n |
| properties | 載入屬性檔作為 Ivy 變數 | 0..n |
| settings | 用一些預設值配置 Ivy | 0..1 |
| include | 包含其他設定檔 | 0..n |
| classpath | 在 classpath 增加位置載入外掛 | 0..n |
| typedef | 在 Ivy 中定義新類型 | 0..n |
| lock-strategies | 定義鎖策略 | 0..1 |
| caches | 定義倉庫快取管理器 | 0..1 |
| latest-strategies | 定義最新策略 | 0..1 |
| parsers | 定義模組描述符解析器 | 0..1 |
| version-matchers | 定義新版本匹配器 | 0..1 |
| triggers | 註冊 Ivy 事件觸發器 | 0..1 |
| namespaces | 定義新命名空間 | 0..1 |
| macrodef | 定義新巨集解析器 | 0..n |
| resolvers | 定義依賴解析器 | 0..1 |
| conflict-managers | 定義衝突管理器 | 0..1 |
| modules | 定義模組與解析器間規則 | 0..1 |
| outputters | 定義可用報告輸出器列表 | 0..1 |
| statuses | 定義可用狀態列表 | 0..1 |