Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the docs for tasks.withType()?

Tags:

gradle

Gradle is a well documented project, but when I search for the docs for tasks.withType(), I only find the API docs.

Isn't this an official part of Gradle?

like image 380
rdmueller Avatar asked Aug 25 '17 12:08

rdmueller


People also ask

Where are tasks defined in Gradle?

5. Define Task Type in the buildSrc Folder. We can define task types in the buildSrc folder which is located at the root project level. Gradle compiles everything that is inside and adds types to the classpath so our build script can use it.

How do I view tasks in Gradle?

Within IntelliJ IDEA, find the check task in the Gradle tool window under verification. Double click it to run. Check is also run when you run the build task, thanks to a task dependency setup by the base plugin. Gradle runs the assemble task then check.

Which are the tasks are performed by Gradle?

The work that Gradle can do on a project is defined by one or more tasks. A task represents some atomic piece of work which a build performs. This might be compiling some classes, creating a JAR, generating Javadoc, or publishing some archives to a repository.

What does Gradle use to determine the order in which tasks can be run?

Gradle determines the subset of the tasks, created and configured during the configuration phase, to be executed. The subset is determined by the task name arguments passed to the gradle command and the current directory. Gradle then executes each of the selected tasks.


1 Answers

One of the fundamental concepts in Gradle is that everything is executed against a Project instance. Once you know that, you can work through the javadoc to find what you want. There's a bit of "magic" to be wary of too (a topic for another conversation) and also groovy syntax to understand .

So tasks.withType(...) can be looked up in the javadocs as Project.getTasks().withType(...).

You'll notice that Project.getTasks() returns a TaskCollection (which you found in your googling)

* edit *

There's a mention here in the docs which links to the TaskContainer javadocs

A project is essentially a collection of Task objects. Each task performs some basic piece of work, such as compiling classes, or running unit tests, or zipping up a WAR file. You add tasks to a project using one of the create() methods on TaskContainer, such as TaskContainer.create(java.lang.String). You can locate existing tasks using one of the lookup methods on TaskContainer, such as TaskCollection.getByName(java.lang.String)

like image 100
lance-java Avatar answered Sep 17 '22 16:09

lance-java