What is a "task type" in gradle?

I can declare the type of the gradient task, and it seems to inherit some methods. For instance:

task myCopyTask(type: Copy){ from "foo" into "bar" } 

So, I think myCopyTask is an instance of class org.gradle.api.tasks.Copy , yes? And if I declare the task without any type, is it an instance of org.gradle.api.DefaultTask ? Sorry for the basic question. I read a graduation manual like this page, but I don’t understand what type: exactly.

+12
source share
3 answers

Why not just add println and recognize yourself?

 task myCopyTask(type: Copy) { ... } println "Type is $myCopyTask.class.name" 
+2
source

He already answered, but it can also help to understand.

These are subclasses of type Task . When you determine the type of your task, you get access to / configure / configure certain properties of the task. In your case, this is a subclass called Copy (as you already found out).

Note. Tasks are sent with various plugins or written by you.

0
source

To get the type of an existing task, you can use the built-in help Gradle with the help --task command line. The --task parameter accepts the task path for any task in the project. Here is an example with help :

 # ./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 
0
source

Source: https://habr.com/ru/post/1013584/


All Articles