How can I get a list of my projects dependencies in a flattened form using Gradle?

为君一笑 提交于 2019-12-03 12:32:42

Here is a short task that meets that need:

task('dependenciesList') <<  {
    println "Compile dependencies"
    def selectedDeps = project.configurations.compile.incoming.resolutionResult.allDependencies.collect { dep ->
        "${dep.selected}"
    }
    selectedDeps.unique().sort().each { println it}
}

The third line is the interesting part. You need to get the configuration you care about (compile) then insead of getting dependencies there, the incoming.resolutionResult will provide the resolved values and versions.

You can flatten the deps tree using sed|sort|uniq in linux or cygwin:

$ gradle dependencies | sed 's/^.* //' | sort | uniq
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!