1) retrieve
retrieve任務復制解析好的依賴到你的文件系統(tǒng)的任何位置。
這是一個post resolve任務,帶有所有post resolve任務共有的所有的行為和屬性。
從1.4起 這個任務甚至可以根據依賴解析的結果用實際應該存在的東西來同步目標目錄。這意味著如果設置sync為"true",ivy不僅將復制必要的文件,而且它還會刪除那些不再需要在那里的文件。
同步實際上是刪除root目標目錄下不再是retrieve任務必須的所有文件和目錄。
root目標目錄是 在目標正則表達式中的標示為第一級別的第一個標記的目錄。
例如:
pattern: lib/[conf]/[artifact].[ext]
root: lib
2) 屬性
屬性 | 描述 | 必要 |
pattern |
the pattern to use to copy the dependencies
用來復制依賴的正則表達式
|
No. 默認為 ${ivy.retrieve.pattern} |
ivypattern |
the pattern to use to copy the ivy files of dependencies since 1.3
從1.3起用來復制依賴的ivy文件的正則表達式
|
No. 默認不獲取依賴的ivy文件 |
conf |
a comma separated list of the configurations to retrieve
用于獲取的配置的列表,逗號分隔
|
No. 默認為被最后一次resolve調用解析好的配置,或者在沒有顯示調用resoleve時的*
|
sync |
true to synchronize the destination, false to just make a copy since 1.4
從1.4起 true 同步目錄路徑,false僅僅復制
|
No. 默認為 false |
type |
comma separated list of accepted artifact types since 1.4
從1.4起 可接受的制品類型列表,逗號分隔
|
No. 默認所有制品類型都被接受 |
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復制制品。符號鏈接的目的地取決于useOrigin屬性的值(從2.0起)
|
No. 默認為 false |
settingsRef |
A reference to the ivy settings that must be used by this task (since 2.0)
必須被這次任務使用的iry設置的引用
|
No, 默認使用'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:
- default
the default log settings, where all usual messages are output to the console
- quiet
disable all usual messages, making the whole retrieve process quiet unless errors occur
|
No, defaults to 'default'. |
3) 示例
1.
<ivy:retrieve />
使用默認參數獲取依賴。這通常獲取最后一次解析調用的所有依賴到lib目錄中。
2.
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]"/>
獲取最后一次解析調用的所有依賴到lib目錄中,依賴將分隔在按照組織命名的目錄中,每個conf目錄包含對應的不帶修訂版本的制品。
例如,如果ivy文件聲明了兩個配置default和test,結果lib目錄將會像這樣:
lib
default
commons-lang.jar
commons-logging.jar
test
junit.jar
注意如果一個依賴被兩個配置要求,它將被復制到兩個目錄中。這個依賴的下載將只在resolve的時候進行一次。
3.
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" sync="true" />
和前面相同,但是開啟同步。
例如,如果ivy文件聲明了兩個配置default和test,結果lib目錄將會像這樣:
lib
default
commons-lang.jar
commons-logging.jar
test
junit.jar
現在假設commons-logging 不再是默認配置的一部分,然后新的retrieve調用將會產生如下結果:
lib
default
commons-lang.jar
test
junit.jar
如果不開啟同步,commons-logging將不會被這次調用刪除。
4.
<ivy:retrieve pattern="${lib.dir}/[type]/[artifact]-[revision].[ext]" conf="runtime"/>
僅僅獲取配置runtime依賴到用制品類型命名的目錄中。結果lib目錄將類似這樣:
lib
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}指出的目錄。