What is the Gradle artifact dependency graph comma

2019-01-06 09:31发布

问题:

I read this comment in the Gradle docs:

To deal with problems due to version conflicts, reports with dependency graphs
are also very helpful. Such reports are another feature of dependency management.

I have some kind of jar being brought in but I need to figure out where it is coming from. Normally I would just globally exclude it, but I need some information on the hierarchy here. How do I get this information like I can from Ivy and Maven?

NOT to mention that someone is bringing Hibernate jars (a lot) in to my jar list and I really want to know who since I am not using Hibernate and try to cut out that dependency.

回答1:

The command is gradle dependencies, and its output is much improved in Gradle 1.2. (You can already try 1.2-rc-1 today.)



回答2:

Ah, since I had no dependencies in my master project, "gradle dependencies" only lists those and not subproject dependencies so the correct command ended up being

 gradle :<subproject>:dependencies

so for me this was

 gradle :master:dependencies


回答3:

If you want to see dependencies on project and all subprojects use in your top-level build.gradle:

subprojects {
    task listAllDependencies(type: DependencyReportTask) {}
}

Then call gradle:

gradle listAllDependencies


回答4:

If you got a lot configurations the output might be pretty lengthy. To just show dependencies for the runtime configuration, run

gradle dependencies --configuration runtime


回答5:

If you want recursive to include subprojects, you can always write it yourself:

Paste into the top-level build.gradle:

task allDeps << {
    println "All Dependencies:"
    allprojects.each { p ->
        println()
        println " $p.name ".center( 60, '*' )
        println()
        p.configurations.all.findAll { !it.allDependencies.empty }.each { c ->
            println " ${c.name} ".center( 60, '-' )
            c.allDependencies.each { dep ->
                println "$dep.group:$dep.name:$dep.version"
            }
            println "-" * 60
        }
    }
}

Run with:

gradle allDeps


回答6:

For those looking to debug gradle dependencies in react-native projects, the command is (executed from projectname/android)

./gradlew app:dependencies --configuration compile


标签: gradle