Skip to content

Instantly share code, notes, and snippets.

@myniva
Last active August 8, 2023 11:22
Show Gist options
  • Save myniva/80b9f98b7eac5b55584d2d1f536b23d5 to your computer and use it in GitHub Desktop.
Save myniva/80b9f98b7eac5b55584d2d1f536b23d5 to your computer and use it in GitHub Desktop.
Prints all inputs of the various tasks of a Gradle project
task printTaskInputs {
doLast {
project.getTasks().each { task ->
println "--------------------------------------------------------------------------------"
println " Task '${project.name}:${task.name}'"
println "--------------------------------------------------------------------------------"
println ""
println "File inputs:"
task.inputs.files.each {
println " - ${it}"
}
println ""
println "Property inputs:"
task.inputs.properties.each {
println " - ${it}"
}
println ""
println "--------------------------------------------------------------------------------"
println ""
}
}
}
@artemptushkin
Copy link

Kotlin DSL

tasks.create("printTaskInputs") {
    doLast {
        project.tasks.forEach {
            println("--------------------------------------------------------------------------------")
            println(" Task '${project.name}:${it.name}'")
            println("--------------------------------------------------------------------------------")
            println("")

            println("File inputs:")
            it.inputs.files.forEach {
                println(" - ${it}")
            }
            println("")

            println("Property inputs:")
            it.inputs.properties.forEach {
                println(" - ${it}")
            }
            println("")

            println("--------------------------------------------------------------------------------")
            println("")
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment