Java 插件給項(xiàng)目增加了許多關(guān)于依賴的配置, 如下所示, 這些配置被分配給許多任務(wù), 比如 compileJava 和 test 等配置
表22.5.Java插件-依賴配置
| 名稱 | 擴(kuò)展 | 被使用時(shí)運(yùn)行的任務(wù) | 含義 |
|---|---|---|---|
| compile | - | compileJava | 編譯時(shí)的依賴 |
| runtime | compile | - | 運(yùn)行時(shí)的依賴 |
| testCompile | compile | compileTestJava | 編譯測(cè)試所需的額外依賴 |
| testRuntime | runtime | test | 僅供運(yùn)行測(cè)試的額外依賴 |
| archives | - | uploadArchives | 項(xiàng)目產(chǎn)生的信息單元(如:jar包) |
| default | runtime | - | 使用其他項(xiàng)目的默認(rèn)依賴項(xiàng),包括該項(xiàng)目產(chǎn)生的信息單元以及依賴 |
圖22.2.Java插件-依賴配置

對(duì)于每個(gè)添加到該項(xiàng)目的資源設(shè)置,java 插件會(huì)添加以下的依賴配置
表22.6.Java插件-資源設(shè)置依賴關(guān)系配置
| 名稱 | 擴(kuò)展 | 被使用時(shí)運(yùn)行的任務(wù) | 含義 |
|---|---|---|---|
| sourceSetCompile | - | compileSourceSetJava | 編譯時(shí)給定資源設(shè)置的依賴 |
| sourceSetRuntime | - | - | 運(yùn)行時(shí)給定資源設(shè)置的依賴 |