I can declare a type for a gradle task and doing so seems to inherit some methods. For example:
task myCopyTask(type: Copy){
from "foo"
into "bar"
}
So, I think myCopyTask
is an instance of org.gradle.api.tasks.Copy
class, yes? And if I declare a task without any type, it is an instance of org.gradle.api.DefaultTask
? Sorry for the basic question. I have been reading the gradle guide like this page but it isn't clear to me what type:
exactly is.
To get the type of an existing task, you can make use of Gradle's built-in help
task using the --task
command line option. The --task
option takes in a task path for any task in the project. Here is an example using the help
task on itself:
# ./gradlew help --task help
> Task :help
Detailed task information for help
Path
:help
Type
Help (org.gradle.configuration.Help)
Options
--task The task to show help for.
Description
Displays a help message.
Group
help
Why not just add a println
and find out yourself?
task myCopyTask(type: Copy) {
...
}
println "Type is $myCopyTask.class.name"
It's already answered but this might help to understand as well.
They're the subclasses of the type Task. Once you define a type for your task, you get to access/set/configure that particular task's properties. In your case, this is a subclass called "Copy" (as you've already kinda figure out).
Note: Tasks are shipped with various plugins or written by you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With