ivy中文參考文檔(15)-ant任務(wù)(3)-retrieve
1) retrieveretrieve任務(wù)復(fù)制解析好的依賴到你的文件系統(tǒng)的任何位置。
這是一個post resolve任務(wù),帶有所有post resolve任務(wù)共有的所有的行為和屬性。
從1.4起 這個任務(wù)甚至可以根據(jù)依賴解析的結(jié)果用實際應(yīng)該存在的東西來同步目標(biāo)目錄。這意味著如果設(shè)置sync為"true",ivy不僅將復(fù)制必要的文件,而且它還會刪除那些不再需要在那里的文件。
同步實際上是刪除root目標(biāo)目錄下不再是retrieve任務(wù)必須的所有文件和目錄。
root目標(biāo)目錄是 在目標(biāo)正則表達式中的標(biāo)示為第一級別的第一個標(biāo)記的目錄。
例如:
pattern: lib/[conf]/[artifact].[ext]
root: lib
2) 屬性
屬性 | 描述 | 必要 |
---|---|---|
pattern | the pattern to use to copy the dependencies 用來復(fù)制依賴的正則表達式 |
No. 默認(rèn)為 ${ivy.retrieve.pattern} |
ivypattern | the pattern to use to copy the ivy files of dependencies since 1.3 從1.3起用來復(fù)制依賴的ivy文件的正則表達式 |
No. 默認(rèn)不獲取依賴的ivy文件 |
conf | a comma separated list of the configurations to retrieve 用于獲取的配置的列表,逗號分隔 |
No. 默認(rèn)為被最后一次resolve調(diào)用解析好的配置,或者在沒有顯示調(diào)用resoleve時的* |
sync | true to synchronize the destination, false to just make a copy since 1.4 從1.4起 true 同步目錄路徑,false僅僅復(fù)制 |
No. 默認(rèn)為 false |
type | comma separated list of accepted artifact types since 1.4 從1.4起 可接受的制品類型列表,逗號分隔 |
No. 默認(rèn)所有制品類型都被接受 |
symlink | true
to create symbolic links, false to copy the artifacts. The destination
of the symbolic links depends on the value of the useOrigin attribute (since 2.0) true 創(chuàng)建符號鏈接,false復(fù)制制品。符號鏈接的目的地取決于useOrigin屬性的值(從2.0起) |
No. 默認(rèn)為 false |
settingsRef | A reference to the ivy settings that must be used by this task (since 2.0) 必須被這次任務(wù)使用的iry設(shè)置的引用 |
No, 默認(rèn)使用'ivy.instance' |
log | the log setting to use during the resolve and retrieve process. (since 2.0) Available options are the same as for resolve when used to trigger resolve automatically (see postresolvetask), or the following for the retrieve process only:
|
No, defaults to 'default'. |
3) 示例
1.
<ivy:retrieve />
使用默認(rèn)參數(shù)獲取依賴。這通常獲取最后一次解析調(diào)用的所有依賴到lib目錄中。2.
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]"/>
獲取最后一次解析調(diào)用的所有依賴到lib目錄中,依賴將分隔在按照組織命名的目錄中,每個conf目錄包含對應(yīng)的不帶修訂版本的制品。例如,如果ivy文件聲明了兩個配置default和test,結(jié)果lib目錄將會像這樣:
lib
default
commons-lang.jar
commons-logging.jar
test
junit.jar
注意如果一個依賴被兩個配置要求,它將被復(fù)制到兩個目錄中。這個依賴的下載將只在resolve的時候進行一次。default
commons-lang.jar
commons-logging.jar
test
junit.jar
3.
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" sync="true" />
和前面相同,但是開啟同步。例如,如果ivy文件聲明了兩個配置default和test,結(jié)果lib目錄將會像這樣:
lib
default
commons-lang.jar
commons-logging.jar
test
junit.jar
現(xiàn)在假設(shè)commons-logging 不再是默認(rèn)配置的一部分,然后新的retrieve調(diào)用將會產(chǎn)生如下結(jié)果:default
commons-lang.jar
commons-logging.jar
test
junit.jar
lib
default
commons-lang.jar
test
junit.jar
如果不開啟同步,commons-logging將不會被這次調(diào)用刪除。default
commons-lang.jar
test
junit.jar
4.
<ivy:retrieve pattern="${lib.dir}/[type]/[artifact]-[revision].[ext]" conf="runtime"/>
僅僅獲取配置runtime依賴到用制品類型命名的目錄中。結(jié)果lib目錄將類似這樣:
lib
jar
commons-lang-1.0.jar
looks-1.1.jar
source
looks-1.1.zip
jar
commons-lang-1.0.jar
looks-1.1.jar
source
looks-1.1.zip
5.
<ivy:retrieve organisation="foo" module="bar" inline="true" pattern="${my.install.dir}/[artifact].[ext]"/>
解析并獲取模塊bar和它的依賴的最新版本到${my.install.dir}指出的目錄。
posted on 2009-08-03 08:34 sky ao 閱讀(2706) 評論(0) 編輯 收藏 所屬分類: project building