是否有可能使用gradle来生成依赖于什么的树?
我有一个项目,并希望找出所有的依赖项,所以我可以通过前向声明等来修剪它.
我曾经使用这个简单的gradle任务将'compile'依赖项复制到特定文件夹:
task copyLibs(type: Copy) {
from configurations.compile
into "$project.rootDir/reports/libs/"
}
Run Code Online (Sandbox Code Playgroud)
但是在使用gradle plugin 3.0.1 for Android Studio和Gradle工具升级到4.1后,它刚刚升级我的Android项目后停止工作.由于https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations现在弃用了依赖配置'compile',我将其更改为'implementation'.但是,我无法使用我的copyLibs任务,因为根据Gradle构建错误输出不允许直接解析配置'implementation':
$ ./gradlew.bat clean build
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:copyLibs'.
> Resolving configuration 'implementation' directly is not allowed
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s …Run Code Online (Sandbox Code Playgroud) android android-studio build.gradle android-gradle-plugin gradle-plugin
基于文档(4.7.6 - 深入了解特定依赖关系),我们可以获得指定配置本身的特定配置的见解.在他们使用的示例中compile,不推荐使用配置.我试图重现相同的命令置换,以build.gradle中,compile与配置implementation配置(如我,我们不应该用compile了).但是当我跑步时:
gradle dependencyInsight --dependency groovy --configuration implementation
Run Code Online (Sandbox Code Playgroud)
Gradle正在回归:
Execution failed for task ':dependencyInsight'.
Resolving configuration 'implementation' directly is not allowed
Run Code Online (Sandbox Code Playgroud)
我的build.gradle文件如下:
apply plugin: 'java-library'
repositories {
jcenter()
}
dependencies{
implementation 'org.codehaus.groovy:groovy-all:2.4.10'
}
Run Code Online (Sandbox Code Playgroud)
这是否意味着如果我正在使用implementation或者是否有另一种获取方式,我无法获得依赖关系的洞察力?