./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, other plugins will not have such a nice pretty graph of the dependencies between tasks.
Is there a way to
- list all the tasks in all plugins with gradle
- list the tasks and what tasks they depend on (sort of like maven's
depenceny:tree
but for tasks)
you can use the --all flag to get a more detailed listing of the available tasks and the task dependencies
gradle tasks --all
EDIT: as noted by Radim in the comments, this command does not report dependencies, for gradle 3.3 and newer.
list the tasks and what tasks they depend on (sort of like maven's
depenceny:tree but for tasks)
for this you can use --dry-run
(or -m
) option which lists tasks which are executed in order for particular command, but does not execute the command, e.g.
gradle assemble --dry-run
you can find more here
You can try com.dorongold.task-tree plugin with simple usage:
gradle <task 1>...<task N> taskTree
gradle --profile clean build
Once this is complete, go to build/reports/profile folder and browse the .html file. You'll see dependencies resolution and other info with time it took in a nice html page.
You can stick this into your build.gradle
:
gradle.taskGraph.whenReady {taskGraph ->
println "Found task graph: " + taskGraph
println "Found " + taskGraph.allTasks.size() + " tasks."
taskGraph.allTasks.forEach { task ->
println task
task.dependsOn.forEach { dep ->
println " - " + dep
}
}
}
Then run your task with gradle:
./gradlew build
And you should see this:
Found task graph: org.gradle.execution.taskgraph.DefaultTaskGraphExecuter@36eb780c
Found 19 tasks.
task ':compileJava'
- task 'compileJava' input files
task ':compileScala'
- task 'compileScala' input files
- compileJava
task ':processResources'
- task 'processResources' input files
task ':classes'
- org.gradle.api.internal.tasks.DefaultTaskDependency@287a7782
- task 'classes' input files
- compileJava
- dirs
- compileScala
- processResources
task ':jar'
- task 'jar' input files
task ':assemble'
- task 'assemble' input files
- org.gradle.api.internal.artifacts.DefaultPublishArtifactSet$ArtifactsTaskDependency@5bad9616
task ':compileTestJava'
- task 'compileTestJava' input files
task ':compileTestScala'
- task 'compileTestScala' input files
- compileTestJava
task ':processTestResources'
- task 'processTestResources' input files
task ':testClasses'
- processTestResources
- task 'testClasses' input files
- compileTestScala
- org.gradle.api.internal.tasks.DefaultTaskDependency@42c1fa08
- compileTestJava
- dirs
task ':compileIntegrationTestJava'
- task 'compileIntegrationTestJava' input files
task ':compileIntegrationTestScala'
- task 'compileIntegrationTestScala' input files
- compileIntegrationTestJava
task ':processIntegrationTestResources'
- task 'processIntegrationTestResources' input files
task ':integrationTestClasses'
- processIntegrationTestResources
- compileIntegrationTestJava
- org.gradle.api.internal.tasks.DefaultTaskDependency@7c8aa0fe
- compileIntegrationTestScala
- dirs
- task 'integrationTestClasses' input files
task ':composeUp'
- task 'composeUp' input files
task ':integrationTest'
- task ':composeUp'
- task 'integrationTest' input files
task ':test'
- task 'test' input files
task ':check'
- task 'check' input files
- task ':test'
- task ':integrationTest'
task ':build'
- task 'build' input files
- check
- assemble
You can programmatically access the task graph to inspect it within the build script using Gradle.getTaskGraph()
As your multiproject grows, the solution I marked as correct grows a bit unweildy and hard to read
gradle tasks --all
Instead, I have moved over to looking at a specific project making it much easier
gradlew :full-httpproxy:tasks --all
where 'full-httpproxy' is the name of my project(and directory as is typical).
I am however curious how to list tasks on the master/root project though and have an outstanding question here as well
How to list all tasks for the master project only in gradle?
as doing that doesn't seem possible right now.