Reputation:
I use Intellij IDEA and gradle for multiple module development environment .
Intellij by default create directory named "out" in gradle module for output compile path .
So some times i want to clean up whole project .
I configure build.gradle and override clean task for this subject , But not work .
task clean {
doLast {
delete 'build', 'target', fileTree("${projectDir}") { include '**/out' }
}
}
actually , I want to delete all subdirectories named "out" .
how can fix this ?
Upvotes: 1
Views: 4003
Reputation: 682
Just to add to SkyWalkers answer, you can also bind your task to the java plug-in 'clean' task, so it runs with the standard clean, by making clean dependent on it:
task cleanBuildDir(type: Delete) {
delete "${projectDir}/out"
}
tasks.clean.dependsOn(cleanBuildDir)
Upvotes: 1
Reputation: 29150
If you want to delete "out" section, you can use the task
task makePretty(type: Delete) {
delete 'out'
}
For more, you can go through this tutorial: How to delete an empty directory (or the directory with all contents recursively) in gradle?
Upvotes: 4