如何列出“编译”配置的“提供”依赖项?我想下载所有的依赖项

时间:2016-09-18 00:56:11

标签: gradle

使用dependencies列出gradle

gradlew dependencies

这将显示当前项目configurations中的所有依赖项。

例如:

testCompile - Classpath for compiling the test sources.
+--- org.robolectric:shadows-support-v4:3.1.2
|    +--- org.robolectric:robolectric:3.1.2
|    |    +--- org.robolectric:robolectric-annotations:3.1.2
|    |    +--- org.robolectric:robolectric-resources:3.1.2
|    |    |    +--- org.robolectric:robolectric-utils:3.1.2
|    |    |    |    +--- org.ow2.asm:asm:5.0.1
|    |    |    |    +--- org.ow2.asm:asm-commons:5.0.1
|    |    |    |    |    \--- org.ow2.asm:asm-tree:5.0.1
|    |    |    |    |         \--- org.ow2.asm:asm:5.0.1
|    |    |    |    +--- org.robolectric:robolectric-annotations:3.1.2
|    |    |    |    \--- com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.1
|    |    |    |         +--- org.hamcrest:hamcrest-core:1.3
|    |    |    |         +--- org.hamcrest:hamcrest-library:1.3
|    |    |    |         |    \--- org.hamcrest:hamcrest-core:1.3
|    |    |    |         \--- com.google.protobuf:protobuf-java:2.6.1
|    |    |    +--- org.robolectric:robolectric-annotations:3.1.2
|    |    |    +--- com.ximpleware:vtd-xml:2.11
|    |    |    \--- com.google.guava:guava:19.0
|    |    +--- org.robolectric:robolectric-utils:3.1.2 (*)
|    |    +--- org.ow2.asm:asm:5.0.1
|    |    +--- org.ow2.asm:asm-util:5.0.1
|    |    |    \--- org.ow2.asm:asm-tree:5.0.1 (*)
|    |    +--- org.ow2.asm:asm-commons:5.0.1 (*)
|    |    +--- org.ow2.asm:asm-analysis:5.0.1
|    |    |    \--- org.ow2.asm:asm-tree:5.0.1 (*)
|    |    +--- org.bouncycastle:bcprov-jdk16:1.46
|    |    +--- com.ximpleware:vtd-xml:2.11
|    |    +--- com.thoughtworks.xstream:xstream:1.4.8
|    |    |    +--- xmlpull:xmlpull:1.1.3.1
|    |    |    \--- xpp3:xpp3_min:1.1.4c
|    |    +--- org.apache.ant:ant:1.8.0
|    |    |    \--- org.apache.ant:ant-launcher:1.8.0
|    |    +--- org.apache.maven:maven-ant-tasks:2.1.3
|    |    |    +--- org.apache.ant:ant:1.8.0 (*)
|    |    |    +--- classworlds:classworlds:1.1-alpha-2
|    |    |    +--- org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1
|    |    |    |    +--- junit:junit:3.8.1 -> 4.12 (*)
|    |    |    |    +--- org.codehaus.plexus:plexus-utils:1.0.4 -> 1.5.15
|    |    |    |    \--- classworlds:classworlds:1.1-alpha-2
|    |    |    +--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    +--- org.codehaus.plexus:plexus-interpolation:1.11
|    |    |    +--- org.apache.maven:maven-artifact:2.2.1
|    |    |    |    \--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    +--- org.apache.maven:maven-artifact-manager:2.2.1
|    |    |    |    +--- org.apache.maven:maven-repository-metadata:2.2.1
|    |    |    |    |    \--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    |    +--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    |    +--- org.apache.maven:maven-artifact:2.2.1 (*)
|    |    |    |    +--- org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1 (*)
|    |    |    |    +--- org.apache.maven.wagon:wagon-provider-api:1.0-beta-6
|    |    |    |    |    \--- org.codehaus.plexus:plexus-utils:1.4.2 -> 1.5.15
|    |    |    |    \--- backport-util-concurrent:backport-util-concurrent:3.1
|    |    |    +--- org.apache.maven:maven-model:2.2.1
|    |    |    |    \--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    +--- org.apache.maven:maven-project:2.2.1
|    |    |    |    +--- org.apache.maven:maven-settings:2.2.1
|    |    |    |    |    +--- org.apache.maven:maven-model:2.2.1 (*)
|    |    |    |    |    +--- org.codehaus.plexus:plexus-interpolation:1.11
|    |    |    |    |    +--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    |    |    \--- org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1 (*)
|    |    |    |    +--- org.apache.maven:maven-profile:2.2.1
|    |    |    |    |    +--- org.apache.maven:maven-model:2.2.1 (*)
|    |    |    |    |    +--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    |    |    +--- org.codehaus.plexus:plexus-interpolation:1.11
|    |    |    |    |    \--- org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1 (*)
|    |    |    |    +--- org.apache.maven:maven-model:2.2.1 (*)
|    |    |    |    +--- org.apache.maven:maven-artifact-manager:2.2.1 (*)
|    |    |    |    +--- org.apache.maven:maven-plugin-registry:2.2.1
|    |    |    |    |    +--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    |    |    \--- org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1 (*)
|    |    |    |    +--- org.codehaus.plexus:plexus-interpolation:1.11
|    |    |    |    +--- org.codehaus.plexus:plexus-utils:1.5.15
|    |    |    |    +--- org.apache.maven:maven-artifact:2.2.1 (*)
|    |    |    |    \--- org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1 (*)
|    |    |    +--- org.apache.maven:maven-error-diagnostics:2.2.1
|    |    |    |    \--- org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1 (*)
|    |    |    +--- org.apache.maven:maven-settings:2.2.1 (*)
|    |    |    +--- org.apache.maven.wagon:wagon-file:1.0-beta-6
|    |    |    |    \--- org.apache.maven.wagon:wagon-provider-api:1.0-beta-6 (*)
|    |    |    +--- org.apache.maven.wagon:wagon-http-lightweight:1.0-beta-6
|    |    |    |    +--- org.apache.maven.wagon:wagon-http-shared:1.0-beta-6
|    |    |    |    |    +--- nekohtml:xercesMinimal:1.9.6.2
|    |    |    |    |    +--- nekohtml:nekohtml:1.9.6.2
|    |    |    |    |    \--- org.apache.maven.wagon:wagon-provider-api:1.0-beta-6 (*)
|    |    |    |    \--- org.apache.maven.wagon:wagon-provider-api:1.0-beta-6 (*)
|    |    |    \--- org.apache.maven.wagon:wagon-provider-api:1.0-beta-6 (*)
|    |    \--- org.robolectric:shadows-core-v23:3.1.2
|    |         +--- org.robolectric:robolectric-annotations:3.1.2
|    |         +--- org.robolectric:robolectric-resources:3.1.2 (*)
|    |         +--- org.robolectric:robolectric-utils:3.1.2 (*)
|    |         +--- com.almworks.sqlite4java:sqlite4java:0.282
|    |         \--- com.ibm.icu:icu4j:53.1
|    \--- org.robolectric:shadows-core-v23:3.1.2 (*)

请注意,shadows-support-v4工件会带来robolectric工件,它会带来依赖关系:org.robolectric:shadows-core-v23:3.1.2

如果我们转到build.gradle文件,我们会注意到有provided个未引入的依赖项:https://github.com/robolectric/robolectric/blob/f68ba6bcb51fb25a28805a3c5f7ffcee2d9560d5/robolectric-shadows/shadows-core/build.gradle#L16

实际pom文件:http://repo1.maven.org/maven2/org/robolectric/robolectric/3.1.2/robolectric-3.1.2.pom。提供的依赖项不会添加到POM,但runtime依赖项是。

如何更深入地列出依赖项的所有依赖项,包括任何provided依赖项?

1 个答案:

答案 0 :(得分:0)

我在这里回答:https://github.com/robolectric/robolectric/issues/2646

对于仍有此问题的人,请事先为您的CI下载所有依赖项和传递依赖项:

subprojects { project ->
    task downloadDependencies(type: Copy) {
        description "Downloads all dependencies."
        group "build"

        from {
            // Use of closure defers evaluation until execution time
            project.configurations
                .findAll { configuration -> configuration.canBeResolved }
                .collect { configuration -> configuration.resolvedConfiguration.lenientConfiguration.files }
        }
        into "$project.buildDir/dependencies"
    }
}

示例:

Step 1: gradlew downloadDependencies
Step 2: gradlew assembleDebug testDebug