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