如何深入了解"实施"配置?

时间:2017-10-18 07:31:24

标签: gradle

根据文档(4.7.6 - Getting the insight into a particular dependency),我们可以获得指定配置本身的特定配置的见解。 在示例中,它们用作配置compile,不推荐使用。 我尝试重现相同的命令,在build.gradle中用compile配置替换implementation配置(因为我得到了我们不应该再使用compile)。 但是当我跑步时:

gradle dependencyInsight --dependency groovy --configuration implementation

Gradle正在回归:

Execution failed for task ':dependencyInsight'.
Resolving configuration 'implementation' directly is not allowed

我的build.gradle文件如下:

apply plugin: 'java-library'

repositories {
    jcenter()
}

dependencies{
    implementation 'org.codehaus.groovy:groovy-all:2.4.10'
}

这是否意味着如果我使用implementation或者是否有另一种方法可以获得它,我无法获得依赖关系的洞察力?

2 个答案:

答案 0 :(得分:6)

我遇到了类似的问题,然后四处询问,得到了这个答案:

配置是compileClasspath。如果您有变体,则每个变体都有一个配置(例如,对于release变体,您的配置将为releaseCompileConfiguration)。


完整示例 - 没有变体:gradle dependencyInsight --dependency groovy --configuration compileClasspath
完整示例 - 发布变体:gradle dependencyInsight --dependency groovy --configuration releaseCompileClasspath

答案 1 :(得分:0)

要获取可以与dependencyInsight一起使用的可用配置的列表,简单的方法如下:

  1. 在android studio视图>工具窗口> Gradle中打开gradle视图
  2. 选择并运行任务“您的应用”>“任务”>“ Android”>“ androidDependencies”

然后,您将获得所有可用配置的所有依赖项列表,只需选择一个并运行:

gradle :mymodule dependencyInsight --dependency okhttp --configuration flavourDebugCompileClasspath

希望有帮助