Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the idea behind task clean on gradle android projects

Tags:

When I create a new project on android studio I see in gradle.build:

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

Whats the idea behind it?

like image 859
Daniel Gomez Rico Avatar asked Oct 11 '16 16:10

Daniel Gomez Rico


People also ask

What does gradle clean task do?

clean will delete a build directory, all your classes will be removed for a fresh compile. assemble will create an archive (JAR) file from your Java project and will run all other tasks that require compile, test and so on.

Is gradle clean necessary?

You don't need to run the clean task. Gradle will track task dependencies and clean appropriate parts for you. Here's an example Gradle project I created to show that the accepted answer is incorrect. If custom tasks don't track their dependencies well (they're bugged), then clean is a workaround.

What is the use of clean project in Android Studio?

Cleaning an Android project simply deletes the build directory. It removes the . class files that are generated when you compile your project and then recompiles again.

What is task clean?

In this way the clean task (with the type=delete) deletes the build directory when it runs. It is useful when you modify some config files like the settings.


1 Answers

In this way the clean task (with the type=delete) deletes the build directory when it runs.

It is useful when you modify some config files like the settings.gradle which can requires a complete clean.

like image 186
Gabriele Mariotti Avatar answered Oct 18 '22 18:10

Gabriele Mariotti