Is there a way to list task dependencies in Gradle?

后端 未结 10 1003
逝去的感伤
逝去的感伤 2020-12-07 10:33

./gradle tasks lists \"some\" of the tasks. Looking at http://gradle.org/docs/current/userguide/java_plugin.html there are hidden ones not listed. Also, othe

10条回答
  •  庸人自扰
    2020-12-07 11:23

    Following the answer by cstroe, the following also prints the input and output files of each Gradle task. This is useful since dependencies are sometimes defined by input/output relations. I.e., if task B uses the outputs of task A, cstroe's answer won't show you the dependency. The following is very primitive but does show the list of input and output files for each task:

    gradle.taskGraph.whenReady {taskGraph ->
        println "Found task graph: " + taskGraph
        println "Found " + taskGraph.allTasks.size() + " tasks."
        taskGraph.allTasks.forEach { task ->
            println()
            println("----- " + task + " -----")
            println("depends on tasks: " + task.dependsOn)
            println("inputs: ")
            task.inputs.getFiles().getFiles().collect { f -> println(" - " + f)}
            println("outputs: ")
            task.outputs.getFiles().getFiles().collect { f -> println(" + " + f)}
        }
    }
    

提交回复
热议问题