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?
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.
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.
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.
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.
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.
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