ivy中文參考文檔(14)-ant任務(2)-resolve
1) 解析解析任務實際解析在ivy文件中描述的依賴,并將解析后的依賴放置到ivy緩存中。
如果在resolve任務前沒有調用configure任務,則將使用默認的configuration (等同于不帶參數的調用configure).
在這個任務調用之后,在ant中有四個屬性被設置:
- ivy.organisation 設置為在用于解析的ivy文件中找到的組織名
- ivy.module 設置為在用于解析的ivy文件中找到的模塊名
- ivy.revision 設置為在用于解析的ivy文件中找到的修訂版本名,或者如果在制定的文件中沒有修訂版本名則是新生成的修訂版本名。
- ivy.resolved.configurations 設置為解析好的configuration列表,逗號分隔。
如果在最后一次解析后被解析的依賴發生了變化,一個額外的屬性將被設置為true,否則為false。
ivy.deps.changed
從2.0起:
如果你設置參數checkIfCompiled為false(默認是true以保持向后兼容),屬性ivy.deps.changed將不被設置。當你有進行多配置下的多模塊構建時這容許完善你的構建。
從2.0起:
額外的,如果resolveId屬性被設置,下列屬性也將被設置:
* ivy.organisation.${resolveId}
* ivy.module.${resolveId}
* ivy.revision.${resolveId}
* ivy.resolved.configurations.${resolveId}
* ivy.deps.changed.${resolveId}
* ivy.module.${resolveId}
* ivy.revision.${resolveId}
* ivy.resolved.configurations.${resolveId}
* ivy.deps.changed.${resolveId}
當ivy完成解析任務時,它將輸出概要來說明解析了什么。概要看起來像這樣:
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 4 | 0 | 0 | 0 || 4 | 0 |
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 4 | 0 | 0 | 0 || 4 | 0 |
---------------------------------------------------------------------
這個表單給出一些關于依賴解析的統計。每行對應于一個解析了的配置。這個表單被劃分為兩個部分:
- modules
- number 在這個配置下被解析的依賴模塊的總數目,包括間接的依賴。
- search 這是需要訪問倉庫的依賴模塊的數目。如果模塊還不在緩存中則需要訪問倉庫,或者要求最新版本,或者一些其他情況(例如,根據checkModified)
- dwnlded 從倉庫下載的依賴的ivy文件的數目。使用清理好的緩存,這個數目可以比模塊的總數目少,如果一些依賴沒有提供ivy文件。
- evicted 被沖突管理器逐出的依賴模塊的數目。
- artifacts
- number 在給定的配置中解析的制品的總數目。
- dwnlded 從倉庫中實際下載的制品的數目。
從1.4起 inline模式容許在沒有ivy文件的情況下通過直接設置需要從倉庫中被解析的模塊調用resolve。對于安裝發布的軟件特別有用,例如ant任務。當inline設置為true,組織模塊和修訂版本屬性被用于指定哪個模塊應該從倉庫中解析。
注意:如果你想要設置標準ivy屬性或者通過其他post-resolve任務重用inline解析的結果,類似retrieve, cachepath, report, ..., 你必須設置keep屬性為true。
3) Resolve 模式
從1.4起 解析模式容許定義當執行解析時ivy應該如果使用依賴修訂版本約束。
有兩個模式可用:
- default 在這個模式下使用默認修訂版本約束(通過 dependency 元素的rev屬性來表示)
- dynamic 在這個模式下使用動態修訂版本約束(通過 dependency 元素的revConstraint屬性來表示)
在解析的過程中,ivy在解析緩存中創建一個文件。這個文件的創建并不是為了支持并發,意味著你不能在同樣的解析緩存中,有同樣模塊的同樣的resolveId的,兩個并發解析。
給開發人員的備注:
在這個任務調用之后,有一個被解析的模塊描述符的引用被設置在ant項目中,id為
"ivy.resolved.descriptor"
5) 屬性
Attribute | Description | Required |
---|---|---|
file | path to the ivy file to use for resolution 用來解析的ivy文件的路徑 |
No. 默認是${ivy.dep.file}或在inline模式下不設值 |
conf | a comma separated list of the configurations to resolve, or '*'. 用于解析的逗號分隔的配置列表,或者'*' Since 2.0, you can also use '*(private)', '*(public)'. Note that when inline is true, the configuration '*' is equivalent as '*(public)'. 從2.0起 你也可以使用'*(private)', '*(public)'.注意當inline為true,配置'*'等同于'*(public)'. |
No. 默認是${ivy.configurations} |
refresh | true to force Ivy to resolve dynamic revision in this resolve process, false to use cached resolved revision since 2.0 true 強制ivy在這次解析過程中解析動態修訂版本,false使用緩存的解析好的修訂版本,從2.0起 |
No. 默認是false |
resolveMode | the resolve mode to use for this dependency resolution process since 2.0 這次依賴解析過程要使用的解析模式,從2.0起 |
No. 默認使用settings中設置的解析模式 |
inline | true to use inline mode, false to resolve an ivy file since 1.4 true使用inline模塊,false解析ivy文件,從1.4起 |
No. 默認為false |
keep | true
to keep the results of the resolve in memory, false to discard them.
When this is false, the standard ivy properties won't be set and other
postresolve-tasks (like retrieve and cachepath) won't be able to resuse
the results of this resolve! true在內存中保持這次的解析的結果,false 拋棄他們。當這個是false時,標準ivy屬性不會設置而且其他post-resolve任務(類似retrieve和cachepath)將不能重用這次解析的結果! |
No. 對于inline模式默認是false,其他情況默認為true |
organisation | the organisation of the module to resolve in inline mode since 1.4 在inline模式下用于解析的模塊的組織名,從1.4起 |
Yes 在inline模式下必須,其他不是 |
module | the name of the module to resolve in inline mode since 1.4 在inline模式下用于解析的模塊的名稱,從1.4起 |
Yes 在inline模式下必須,其他不是 |
revision | the revision constraint to apply to the module to resolve in inline mode since 1.4 在inline模式下適用于要解析的模塊的修訂版本約束,從1.4起 |
No. 在inline模式下默認為 "latest.integration",在標準模式下不設置 |
branch | the name of the branch to resolve in inline mode (since 2.1.0) 在inline模式下用于解析的分支的名字(從2.1.0起) |
在inline模式下默認為沒有分支,標準模式下沒有意義 |
type | comma separated list of accepted artifact types (since 1.2) 逗號分隔的可以接受的制品類型列表(從1.2起) |
No. 默認為${ivy.resolve.default.type.filter} |
haltonfailure | true to halt the build on ivy failure, false to continue true 在ivy失敗時掛起整個構建,false 繼續 |
No. 默認為true |
failureproperty | the name of the property to set if the resolve failed since 1.4 在解析失敗失敗時設置的屬性名稱,從1.4起 |
No. 默認沒有屬性被設置 |
transitive | true to resolve dependencies transitively, false otherwise since 1.4 true解析間接依賴,false 不解析,從1.4起 |
No. 默認為true |
showprogress | true to show dots while downloading, false otherwise true在下載過程中顯示點,false不顯示 |
No. 默認為true |
validate | true to force ivy files validation against ivy.xsd, false to force no validation true強制對ivy文件用ivy.xsd驗證,false強制不驗證。 |
No. 默認為ivy的默認值(在配置文件中配置) |
settingsRef | A reference to the ivy settings that must be used by this task (since 2.0) 必須在這次任務中使用的ivy設置的引用(從2.0起) |
No, 默認使用'ivy.instance' |
resolveId | 后面可以用來引用這次解析的結果的id | No, 默認為'[org]-[module]'. |
log | 在解析過程中使用的日志設置(從2.0起) 可使用的選項是:
|
No, 默認為'default'. |
checkIfChanged | When set to true, the resolve will compare the result with the last resolution done on this module, with those configurations 當設置為true時,解析將比較這次的結果和這個模塊的最后一次解析,使用那些配置 |
No, 默認為'true' |
6) 示例
<ivy:resolve file="path/to/ivy.xml"/>
解析在path/to/ivy.xml文件中聲明的所有依賴。<ivy:resolve file="path/to/ivy.xml" transitive="false" />
和上面相同,但是不解析間接依賴。<ivy:resolve file="path/to/ivy.xml" conf="default, test"/>
解析在path/to/ivy.xml文件配置default和test中聲明的依賴。<ivy:resolve file="path/to/ivy.xml" type="jar"/>
解析在path/to/ivy.xml文件中聲明的所有依賴,但是只下載jar制品。<ivy:resolve organisation="apache" module="commons-lang" revision="2+" inline="true" />
從倉庫中解析commons-lang模塊的2+修訂版本,和它的依賴。posted on 2009-08-02 13:18 sky ao 閱讀(2316) 評論(0) 編輯 收藏 所屬分類: project building