简体   繁体   中英

What is type in Gradle task?

Hi, I'm almost new at Gradle in Android. So.. I'm leanring the Gradle but there are many things that I don't understand.

task clean(type: Delete) {
    println "task clean~~"
    delete rootProject.buildDir
}

In project A when I input "gradlew" in Android Studio Terminal, I can see below result.

C:\Users\xxxx\AndroidStudioProjects\ProjectA>gradlew

> Configure project :
task clean~~

(..snip..)

I have questions:

  1. Why is the task clean executed?
  2. Is it default task?

I couldn't find something like below code in the project's gradle file.

defaultTasks 'clean', 'run' .

  1. What is type in task? (I saw type "Copy" too) .

Well task clean is a default task of gradle. It runs every time you start your android studio. To know the working of gradle you should read this gradle documentation which will surely help you in your questions: Gradle Docs

And for the second point according to gradle documentation: A Task represents a single atomic piece of work for a build, such as compiling classes or generating javadoc. So actually it's a task not type, type is a general term and to be specific task type belongs to central types which are used in Gradle scripts . If you go through the documentation you will also find the type:Copy too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM