You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Gradle dependencies任务中指定多个配置?求助

Gradle dependencies任务指定多配置的正确方法

首先纠正两个关键问题:

  • 你写错了配置名:Gradle的标准编译类路径配置是compileClasspath,不是compiletimeClassPath(注意拼写和大小写)
  • 多配置的命令格式需要调整

正确命令写法

方式1:多次使用--configuration参数(兼容所有Gradle版本)

gradle -q dependencies --configuration testRuntimeClasspath --configuration compileClasspath

方式2:逗号分隔配置名(需用引号包裹,适用于Gradle 6.0+版本)

gradle -q dependencies --configuration "testRuntimeClasspath,compileClasspath"

方式3:显式指定任务+配置名

也可以直接通过任务名加配置名的形式调用,效果一致:

gradle -q dependencies:testRuntimeClasspath dependencies:compileClasspath

之前报错的原因

  1. 配置名拼写错误:compiletimeClassPath不是Gradle的标准配置,导致找不到对应配置报错
  2. 逗号分隔时未加引号:shell会将逗号解析为参数分隔符,导致Gradle只识别第一个配置,第二个被当作无效参数

内容的提问来源于stack exchange,提问作者Mohammed Az

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 20:19:53