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?
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?
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)
Project docs which links to TaskContainer javadocsgetFoo(), setFoo(val). In this case, Project.tasks is a plain old JavaBean style property, which would translate to Project.getTasks() in Java. In Groovy, properties are accessed by name and the getter/setter is called transparently, groovy-lang.org/…
org.gradle.api.Project: This interface is the main API to interact with Gradle from inside the build file build.gradle.kts. So insidebuild.gradle.ktsI callgetTasks()method to obtain and interact with tasks of this project. But alternatively looking intoorg.gradle.api.tasks.TaskCollection: You can obtain a TaskContainer instance by calling Project.getTasks(), or using the tasks property in your build script so I continue using thetasksproperty ... etc. etc.