Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all tasks for the master project only in gradle?

Tags:

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

like image 853
Dean Hiller Avatar asked Jul 13 '16 22:07

Dean Hiller


People also ask

How do I list all tasks in Gradle?

To get an overview of all Gradle tasks in our project, we need to run the tasks task. Since Gradle 5.1, we can use the --group option followed by a group name. Gradle will then show all tasks belonging to the group and not the other tasks in the project.

Which are the tasks are performed by Gradle?

Gradle Tasks In Gradle, Task is a single unit of work that a build performs. These tasks can be compiling classes, creating a JAR, Generating Javadoc, and publishing some archives to a repository and more. It can be considered as a single atomic piece of work for a build process.

Where are Gradle tasks defined?

You define a Gradle task inside the Gradle build script. You can define the task pretty much anywhere in the build script. A task definition consists of the keyword task and then the name of the task, like this: task myTask. This line defines a task named myTask .

Which command is used to view the list of available projects in Gradle?

Gradle allows us to list all the essential tasks of the project. To list the task, run the below command: gradle -q tasks.


2 Answers

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
----------------
.....
like image 194
Hang Avatar answered Sep 23 '22 06:09

Hang


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]
like image 36
Dean Hiller Avatar answered Sep 19 '22 06:09

Dean Hiller