What is the Gradle artifact dependency graph command?

前端 未结 8 1405
独厮守ぢ
独厮守ぢ 2020-11-28 03:34

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 ar         


        
相关标签:
8条回答
  • 2020-11-28 04:03

    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
    
    0 讨论(0)
  • 2020-11-28 04:06

    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
    
    0 讨论(0)
  • 2020-11-28 04:09

    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
    
    0 讨论(0)
  • 2020-11-28 04:20

    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
    
    0 讨论(0)
  • 2020-11-28 04:22

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

    0 讨论(0)
  • 2020-11-28 04:26
    gradlew -q :app:dependencies > dependencies.txt
    

    Will write all dependencies to the file dependencies.txt

    0 讨论(0)
提交回复
热议问题