I use following task to delete a folder in current module :
task clearJar(type: Delete) {
delete 'build/generated/'
}
To delete from another module in the same project:
delete project(':test').file('build/')
What if I want to delete a folder in root project in build.gradle under a module?
This worked for me:
delete "$rootProject.projectDir/build/"
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