user9321096
user9321096

Reputation:

gradle delete intellij IDEA out directories

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

Answers (2)

Eurospoofer
Eurospoofer

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

SkyWalker
SkyWalker

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

Related Questions