Gradle 脚本中的渐变依赖层次结构

Gradle 脚本中的渐变依赖层次结构,gradle,dependencies,Gradle,Dependencies,我的目标是打印包含层次结构的gradle构建的依赖项。其思想是以图形方式构建依赖关系图。我需要的信息与我键入gradle dependencies时的信息相同 我怎样才能做到这一点?当我创建自己的任务时,我从哪里获得信息?我只是一个新手,所以也许你的问题有深度,我看不出来。你是说: > gradle dependencies :dependencies ------------------------------------------------------------ Root pr

我的目标是打印包含层次结构的gradle构建的依赖项。其思想是以图形方式构建依赖关系图。我需要的信息与我键入gradle dependencies时的信息相同


我怎样才能做到这一点?当我创建自己的任务时,我从哪里获得信息?

我只是一个新手,所以也许你的问题有深度,我看不出来。你是说:

> gradle dependencies
:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

archives - Configuration for archive artifacts.
No dependencies

compile - Compile classpath for source set 'main'.
\--- commons-collections:commons-collections:3.2

default - Configuration for default artifacts.
\--- commons-collections:commons-collections:3.2

runtime - Runtime classpath for source set 'main'.
\--- commons-collections:commons-collections:3.2

testCompile - Compile classpath for source set 'test'.
+--- commons-collections:commons-collections:3.2
\--- junit:junit:4.+ -> 4.12
     \--- org.hamcrest:hamcrest-core:1.3

testRuntime - Runtime classpath for source set 'test'.
+--- commons-collections:commons-collections:3.2
\--- junit:junit:4.+ -> 4.12
     \--- org.hamcrest:hamcrest-core:1.3

BUILD SUCCESSFUL

Total time: 4.47 secs
这是从
build.gradle
文件创建的,该文件仅具有以下直接依赖项:

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

也许这就是你想要的:

project.configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
 println it.name // << the artifact name
 println it.file // << the file reference
}
project.configurations.compile.resolvedConfiguration.resolvedArtifacts.each{

println it.name//是的,这是gradle提供给我的。但是我想影响输出。生成一个点图。因此我需要一个任务,例如“depentensionesdottraph”它遍历所有这些依赖项并打印图形。但是,我不知道需要访问哪些对象才能遍历依赖项的层次结构并打印htem…如果您想解析
gradle依赖项的输出,Perl是您的朋友。
!:-)这就是我需要的