Why is the build.gradle project for Android a regular “clean” task?

When creating a new project in Android Studio (version 2.1), the root build.gradle file performs the following task:

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

I noticed that some Android projects do not have this custom task and use gradle clean task by default. What is the disadvantage if you do not have the above user-defined clean task?

+5
source share
2 answers

This will delete the entire assembly directory when compiling the code and starting the project. This is done in order to do a full cleanup if you modify some Gradle configuration files. For this reason, it is important not to create the directory inside the / build / folder, as it will be deleted when Gradle starts a clean task. Additional information at https://developer.android.com/studio/build/build-cache.html#clear_the_build_cache

+1
source

As you said, this template is most likely new in the new projects template. It would be easy to override it for the trend apt (compilation of annotation processing time) library that generates codes to clear them.

-1
source

All Articles