How to list all tasks for the master project only

2019-05-11 07:28发布

问题:

I asked this question a long time ago....

Is there a way to list task dependencies in Gradle?

and annotated what I do these days as my project has grown to an unweildy task count. I can then list all tasks for a certain project like

./gradlew :core:core-channelmanager2:asynch-server:tasks --all

and this gives me a nice task list and dependencies of JUST that project. My master root project however does not have many of the plugins my subprojects have since it doesn't need them, but I still need to understand it's task list. I know I can do this

./gradlew tasks --all

but that prints the world. I can't seem to do this

./gradlew :master:tasks --all

nor this

./gradlew :webpieces:tasks --all

where webpieces is my project here ... https://github.com/deanhiller/webpieces/blob/master/build.gradle

Is there a way to list ALL the root projects task so I can get a clear picture of my root project?

thanks, Dean

回答1:

Try this command

$ ./gradlew -q :tasks --all

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]

Build Type tasks
----------------
.....


回答2:

Well, I found a 'slight' workaround that sort of works. I added this code

task printTasks << {
    project.tasks.collect { task -> println("task="+task+" dependsOn="+task.dependsOn) }
}

but then some of the things they depend on are 'fileCollection' when it prints so it 'half' works. I am not sure what these fileCollection things are in the list of dependencies...that is a bit weird.

EDIT: oops, a darn closure so I can't see what it actually depends on

:printTasks
task=task ':closeAndPromoteRepository' dependsOn=[task ':promoteRepository', file collection, task ':closeRepository']
task=task ':closeRepository' dependsOn=[file collection, uploadArchives2]
task=task ':getStagingProfile' dependsOn=[file collection]
task=task ':printTasks' dependsOn=[file collection]
task=task ':promoteRepository' dependsOn=[file collection, closeRepository]
task=task ':release' dependsOn=[file collection, :webserver:githubRelease]
task=task ':taskTree' dependsOn=[file collection]
task=task ':uploadArchives2' dependsOn=[build_eiigg76myo3wuvq219kdx5rxk$_run_closure7@5c1c5fde, file collection]


标签: gradle