如何检查构建 gradle 脚本的解析依赖项。例如,我有插件 1 和插件 2,我怎样才能弄清楚是什么依赖关系拉动了它们,并且分别拉动了它们?
是否有任何参数可以打印出此信息?
如何检查构建 gradle 脚本的解析依赖项。例如,我有插件 1 和插件 2,我怎样才能弄清楚是什么依赖关系拉动了它们,并且分别拉动了它们?
是否有任何参数可以打印出此信息?
最新的 gradle 版本附带了buildEnvironment
完全符合您需要的任务。你可以简单地运行
gradle buildEnvironment
您可以使用gradle dependencies
获取完整列表。如果您只对特定模块感兴趣,那么您可以使用gradle app:dependencyInsight --dependency com.google.code.gson
示例gson
所有依赖示例输出都来自项目:https ://github.com/JBirdVegas/external_jbirdvegas_mGerrit
这是一个示例输出
$ gradle dependencies app:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
No configurations
:app:dependencies
------------------------------------------------------------
Project :app
------------------------------------------------------------
_debugAndroidTestApk - ## Internal use, do not manually configure ##
\--- com.android.support:multidex-instrumentation:1.0.1
\--- com.android.support:multidex:1.0.1
_debugAndroidTestCompile - ## Internal use, do not manually configure ##
\--- com.android.support:multidex-instrumentation:1.0.1
\--- com.android.support:multidex:1.0.1
_releaseUnitTestApk - ## Internal use, do not manually configure ##
No dependencies
_releaseUnitTestCompile - ## Internal use, do not manually configure ##
No dependencies
androidJacocoAgent - The Jacoco agent to use to get coverage data.
\--- org.jacoco:org.jacoco.agent:0.7.4.201502262128
androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
\--- org.jacoco:org.jacoco.ant:0.7.4.201502262128
+--- org.jacoco:org.jacoco.core:0.7.4.201502262128
| \--- org.ow2.asm:asm-debug-all:5.0.1
+--- org.jacoco:org.jacoco.report:0.7.4.201502262128
| +--- org.jacoco:org.jacoco.core:0.7.4.201502262128 (*)
| \--- org.ow2.asm:asm-debug-all:5.0.1
\--- org.jacoco:org.jacoco.agent:0.7.4.201502262128
androidTestApk - Classpath packaged with the compiled 'androidTest' classes.
No dependencies
androidTestCompile - Classpath for compiling the androidTest sources.
No dependencies
androidTestProvided - Classpath for only compiling the androidTest sources.
No dependencies
androidTestWearApp - Link to a wear app to embed for object 'androidTest'.
No dependencies
apk - Classpath packaged with the compiled 'main' classes.
No dependencies
archives - Configuration for archive artifacts.
No dependencies
checkstyle - The Checkstyle libraries to be used for this project.
Download https://repo1.maven.org/maven2/com/puppycrawl/tools/checkstyle/5.9/checkstyle-5.9.pom
\--- com.puppycrawl.tools:checkstyle:5.9
+--- antlr:antlr:2.7.7
+--- commons-beanutils:commons-beanutils-core:1.8.3
+--- commons-cli:commons-cli:1.2
\--- com.google.guava:guava-jdk5:14.0.1
compile - Classpath for compiling the main sources.
+--- com.jakewharton.hugo:hugo-annotations:1.2.1
+--- com.android.support:appcompat-v7:23.1.1
| \--- com.android.support:support-v4:23.1.1
| \--- com.android.support:support-annotations:23.1.1
+--- com.android.support:design:23.1.1
| +--- com.android.support:appcompat-v7:23.1.1 (*)
| +--- com.android.support:recyclerview-v7:23.1.1
| | +--- com.android.support:support-annotations:23.1.1
| | \--- com.android.support:support-v4:23.1.1 (*)
| \--- com.android.support:support-v4:23.1.1 (*)
+--- com.google.code.gson:gson:2.4
+--- com.mcxiaoke.volley:library:1.0.18
+--- com.nhaarman.listviewanimations:lib-core:3.1.0
+--- com.nhaarman.listviewanimations:lib-core-slh:3.1.0
+--- com.nineoldandroids:library:2.4.0
+--- de.greenrobot:eventbus:2.4.0
+--- joda-time:joda-time:2.7
+--- org.ajoberstar:gradle-git:1.1.0
| +--- org.ajoberstar:grgit:1.1.0
| | +--- org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r
| | | +--- com.jcraft:jsch:0.1.50
| | | +--- com.googlecode.javaewah:JavaEWAH:0.7.9
| | | +--- org.apache.httpcomponents:httpclient:4.1.3
| | | | +--- org.apache.httpcomponents:httpcore:4.1.4
| | | | +--- commons-logging:commons-logging:1.1.1
| | | | \--- commons-codec:commons-codec:1.4
| | | \--- org.slf4j:slf4j-api:1.7.2 -> 1.7.7
| | +--- org.eclipse.jgit:org.eclipse.jgit.ui:3.7.0.201502260915-r
| | | \--- org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r (*)
| | +--- com.jcraft:jsch.agentproxy.jsch:0.0.7
| | | +--- com.jcraft:jsch:0.1.49 -> 0.1.50
| | | \--- com.jcraft:jsch.agentproxy.core:0.0.7
| | +--- com.jcraft:jsch.agentproxy.pageant:0.0.7
| | | +--- com.jcraft:jsch.agentproxy.core:0.0.7
| | | +--- net.java.dev.jna:jna:3.4.0
| | | \--- net.java.dev.jna:platform:3.4.0
| | +--- com.jcraft:jsch.agentproxy.sshagent:0.0.7
| | | \--- com.jcraft:jsch.agentproxy.core:0.0.7
| | +--- com.jcraft:jsch.agentproxy.usocket-jna:0.0.7
| | | +--- com.jcraft:jsch.agentproxy.core:0.0.7
| | | +--- net.java.dev.jna:jna:3.4.0
| | | \--- net.java.dev.jna:platform:3.4.0
| | +--- com.jcraft:jsch.agentproxy.usocket-nc:0.0.7
| | | \--- com.jcraft:jsch.agentproxy.core:0.0.7
| | \--- org.slf4j:slf4j-api:1.7.7
| \--- com.github.zafarkhaja:java-semver:0.8.0
+--- se.emilsjolander:stickylistheaders:2.6.0
+--- com.github.dmytrodanylyk.android-process-button:library:1.0.3
+--- de.hdodenhof:circleimageview:1.2.2
+--- com.google.guava:guava:18.0
+--- org.apache.httpcomponents:httpclient-android:4.3.5.1
+--- com.android.support:multidex:1.0.1
+--- com.anupcowkur:reservoir:2.1
| +--- com.jakewharton:disklrucache:2.0.2
| +--- com.google.code.gson:gson:2.2.4 -> 2.4
| +--- commons-io:commons-io:2.4
| \--- io.reactivex:rxandroid:0.24.0
| \--- io.reactivex:rxjava:1.0.4
\--- com.mikepenz:materialdrawer:4.5.5
+--- com.android.support:recyclerview-v7:23.1.1 (*)
+--- com.mikepenz:materialize:0.5.1
+--- com.mikepenz:iconics-core:2.5.0
\--- com.android.support:support-annotations:23.1.1
debugApk - Classpath packaged with the compiled 'debug' classes.
No dependencies
debugCompile - Classpath for compiling the debug sources.
+--- com.jakewharton.hugo:hugo-runtime:1.2.1
| +--- com.jakewharton.hugo:hugo-annotations:1.2.1
| \--- org.aspectj:aspectjrt:1.8.5
\--- org.aspectj:aspectjrt:1.8.5
以 app:dependencyInsight 为例gson
$ gradle app:dependencyInsight --configuration compile --dependency com.google.code.gson
:app:dependencyInsight
com.google.code.gson:gson:2.4 (conflict resolution)
\--- compile
com.google.code.gson:gson:2.2.4 -> 2.4
\--- com.anupcowkur:reservoir:2.1
\--- compile
BUILD SUCCESSFUL
Total time: 1.018 secs
编辑: 要获得构建脚本依赖项,我认为您需要一个自定义任务......像这样
task buildScriptDependencies(type: org.gradle.api.tasks.diagnostics.DependencyReportTask) {
configurations = project.buildscript.configurations
}
然后就可以从命令行快速获取构建脚本依赖:
$ gradle buildScriptDependencies
Configuration on demand is an incubating feature.
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE
versionCode: 2111073 versionName: 2.111.73
Applying signing plugin
Not signing release. keyStoreFile was not defined in private.creds
Adding git task
WARNING: Dependency org.apache.httpcomponents:httpclient:4.1.3 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.1.3 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Adding javadoc task
Adding style task
:buildScriptDependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
+--- com.android.tools.build:gradle:1.5.0
| \--- com.android.tools.build:gradle-core:1.5.0
| +--- com.android.tools.build:builder:1.5.0
| | +--- com.android.tools.build:builder-model:1.5.0
| | | \--- com.android.tools:annotations:24.5.0
| | +--- com.android.tools.build:builder-test-api:1.5.0
| | | \--- com.android.tools.ddms:ddmlib:24.5.0
| | | +--- com.android.tools:common:24.5.0
| | | | +--- com.android.tools:annotations:24.5.0
| | | | \--- com.google.guava:guava:17.0
| | | \--- net.sf.kxml:kxml2:2.3.0
| | +--- com.android.tools.build:transform-api:1.5.0
| | | +--- com.android.tools:annotations:24.5.0
| | | \--- com.google.guava:guava:17.0
| | +--- com.android.tools:sdklib:24.5.0
| | | +--- com.android.tools.layoutlib:layoutlib-api:24.5.0
| | | | +--- com.android.tools:common:24.5.0 (*)
| | | | +--- net.sf.kxml:kxml2:2.3.0
| | | | +--- com.android.tools:annotations:24.5.0
| | | | \--- com.intellij:annotations:12.0
| | | +--- com.android.tools:dvlib:24.5.0
| | | | \--- com.android.tools:common:24.5.0 (*)
| | | +--- com.google.code.gson:gson:2.2.4
| | | +--- org.apache.commons:commons-compress:1.8.1
| | | +--- org.apache.httpcomponents:httpclient:4.1.1
| | | | +--- org.apache.httpcomponents:httpcore:4.1
| | | | +--- commons-logging:commons-logging:1.1.1
| | | | \--- commons-codec:commons-codec:1.4
| | | \--- org.apache.httpcomponents:httpmime:4.1
| | | +--- org.apache.httpcomponents:httpcore:4.1
| | | \--- commons-logging:commons-logging:1.1.1
| | +--- com.android.tools:sdk-common:24.5.0
| | | +--- com.android.tools:sdklib:24.5.0 (*)
| | | +--- com.android.tools.build:builder-test-api:1.5.0 (*)
| | | \--- com.android.tools.build:builder-model:1.5.0 (*)
| | +--- com.android.tools:common:24.5.0 (*)
| | +--- com.android.tools.build:manifest-merger:24.5.0
| | | +--- com.android.tools:common:24.5.0 (*)
| | | +--- com.android.tools:sdklib:24.5.0 (*)
| | | +--- com.android.tools:sdk-common:24.5.0 (*)
| | | +--- net.sf.kxml:kxml2:2.3.0
| | | \--- com.google.code.gson:gson:2.2.4
| | +--- com.android.tools.ddms:ddmlib:24.5.0 (*)
| | +--- com.android.tools.jack:jack-api:0.9.0
| | +--- com.android.tools.jill:jill-api:0.9.0
| | +--- com.squareup:javawriter:2.5.0
| | +--- org.bouncycastle:bcpkix-jdk15on:1.48
| | | \--- org.bouncycastle:bcprov-jdk15on:1.48
| | +--- org.bouncycastle:bcprov-jdk15on:1.48
| | +--- org.ow2.asm:asm:5.0.3
| | +--- org.ow2.asm:asm-tree:5.0.3
| | | \--- org.ow2.asm:asm:5.0.3
| | +--- org.antlr:antlr-runtime:3.5.2
| | \--- org.antlr:antlr:3.5.2
| | +--- org.antlr:antlr-runtime:3.5.2
| | \--- org.antlr:ST4:4.0.8
| | \--- org.antlr:antlr-runtime:3.5.2
| +--- com.android.tools.lint:lint:24.5.0
| | +--- com.android.tools.lint:lint-checks:24.5.0
| | | +--- com.android.tools.lint:lint-api:24.5.0
| | | | +--- com.android.tools:sdk-common:24.5.0 (*)
| | | | +--- com.android.tools.build:builder-model:1.5.0 (*)
| | | | +--- com.android.tools.external.lombok:lombok-ast:0.2.3
| | | | | \--- com.google.guava:guava:17.0
| | | | +--- org.ow2.asm:asm:5.0.3
| | | | \--- org.ow2.asm:asm-tree:5.0.3 (*)
| | | \--- org.ow2.asm:asm-analysis:5.0.3
| | | \--- org.ow2.asm:asm-tree:5.0.3 (*)
| | \--- org.eclipse.jdt.core.compiler:ecj:4.4.2
| +--- com.android.tools.build:transform-api:1.5.0 (*)
| +--- com.android.databinding:compilerCommon:1.0-rc5
| | +--- com.android.databinding:baseLibrary:1.0-rc5
| | +--- org.apache.commons:commons-lang3:3.3.2
| | +--- com.tunnelvisionlabs:antlr4:4.5
| | | +--- com.tunnelvisionlabs:antlr4-runtime:4.5
| | | | +--- org.abego.treelayout:org.abego.treelayout.core:1.0.1
| | | | \--- com.tunnelvisionlabs:antlr4-annotations:4.5
| | | +--- com.tunnelvisionlabs:antlr4-annotations:4.5
| | | +--- org.antlr:antlr-runtime:3.5.2
| | | \--- org.antlr:ST4:4.0.8 (*)
| | +--- commons-io:commons-io:2.4
| | \--- com.googlecode.juniversalchardet:juniversalchardet:1.0.3
| +--- net.sf.proguard:proguard-gradle:5.2.1
| | \--- net.sf.proguard:proguard-base:5.2.1
| \--- org.jacoco:org.jacoco.core:0.7.4.201502262128
| \--- org.ow2.asm:asm-debug-all:5.0.1
\--- com.gradle:build-receipt-plugin:1.0
(*) - dependencies omitted (listed previously)
BUILD SUCCESSFUL
Total time: 0.961 secs