執(zhí)行 gradle dependencies 命令會列出項目的依賴列表, 所有依賴會根據(jù)任務區(qū)分,以樹型結構展示出來.
如下例:
例 11.13. 獲取依賴信息
gradle -q dependencies api:dependencies webapp:dependencies 的輸出結果
> 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
雖然輸出結果很多,
但這對于了解構建任務十分有用,
當然你可以通過 --configuration 參數(shù)來查看 指定構建任務的依賴情況:
例 11.14. 過濾依賴信息
gradle -q api:dependencies --configuration testCompile 的輸出結果
> 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