簡體   English   中英

使 gradle 依賴項任務在其結果中排除測試依賴項

[英]make gradle dependency task to exclude test dependencies in its result

當我運行./gradlew dependencies我會得到整個依賴項樹,包括 prod/main 和 test。

如何在依賴項任務的結果中獲取僅生產/主要依賴項的列表

官方文檔https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html建議如何顯示特定配置所需的依賴項,例如 Java 項目中的測試運行時類路徑:

`gradle -q dependencies --configuration testRuntimeClasspath`

谷歌搜索后,我發現命令gradlew dependencies --configuration compileClasspath它的結果是否也包含運行時依賴項?

如何獲取依賴項列表,不包括依賴項任務結果中的測試依賴項?

如果您想要的是“生產”運行時依賴項,請使用--configuration runtimeClasspath

Gradle 中的配置就像依賴項的桶。 由 Java 插件貢獻的那些在這里描述。

最有趣的是這些:

  • compileClasspath :編譯項目所需的依賴項。 擴展 extends compile (deprecated), compileOnlyimplementation
  • runtimeClasspath :運行時所需的依賴項。 擴展runtime (deprecated), runtimeOnlyimplementation

正如您所注意到的,上述兩個版本還有用於編譯和運行單元測試的“測試”版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM