Gradle獲取依賴列表

2020-07-24 15:54 更新

執(zhí)行 gradle dependencies 命令會(huì)列出項(xiàng)目的依賴列表, 所有依賴會(huì)根據(jù)任務(wù)區(qū)分,以樹型結(jié)構(gòu)展示出來. 如下例:

例 11.13. 獲取依賴信息

gradle -q dependencies api:dependencies webapp:dependencies 的輸出結(jié)果

> gradle -q dependencies api:dependencies webapp:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------

No configurations

------------------------------------------------------------
Project :api - The shared API for the application
------------------------------------------------------------

compile
\--- org.codehaus.groovy:groovy-all:2.3.3

testCompile
\--- junit:junit:4.11
     \--- org.hamcrest:hamcrest-core:1.3

------------------------------------------------------------
Project :webapp - The Web application implementation
------------------------------------------------------------

compile
+--- project :api
|    \--- org.codehaus.groovy:groovy-all:2.3.3
\--- commons-io:commons-io:1.2

testCompile
No dependencies

雖然輸出結(jié)果很多, 但這對(duì)于了解構(gòu)建任務(wù)十分有用, 當(dāng)然你可以通過 --configuration 參數(shù)來查看 指定構(gòu)建任務(wù)的依賴情況:

例 11.14. 過濾依賴信息

gradle -q api:dependencies --configuration testCompile 的輸出結(jié)果

> gradle -q api:dependencies --configuration testCompile
------------------------------------------------------------
Project :api - The shared API for the application
------------------------------------------------------------

testCompile
\--- junit:junit:4.11
     \--- org.hamcrest:hamcrest-core:1.3


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)