Created
May 28, 2019 09:48
-
-
Save johnkil/73489af8e14234bf120d35b70e9d1c03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task deleteBuildDirs(type: Delete) { | |
doLast { | |
def buildDirs = [] | |
file(".").eachFileRecurse(groovy.io.FileType.DIRECTORIES) { File file -> | |
if (file.name == "build") { | |
buildDirs << file | |
} | |
} | |
buildDirs.reverseEach { | |
println "Removing ${it.path}" | |
it.deleteDir() | |
} | |
} | |
} | |
task deleteEmptyDirs() { | |
def emptyDirs = [] | |
project.fileTree(dir: '.') | |
.matching { include { element -> element.directory } } | |
.visit { element -> | |
if (project.fileTree(element.file).filter { it.isFile() }.files.size() == 0) { | |
emptyDirs << element.file | |
} | |
} | |
emptyDirs.reverseEach { dir -> | |
println "Removing $dir" | |
project.delete(dir) | |
} | |
} | |
task deleteIdeaFiles(type: Delete) { | |
println "Removing ${rootProject.rootDir}/.idea" | |
delete ".idea" | |
file(".").eachFileRecurse(groovy.io.FileType.FILES) { File file -> | |
//Delete all files *.iml | |
if (file.name.endsWith('.iml')) { | |
println "Removing ${file.path}" | |
delete file | |
} | |
} | |
} | |
task cleanAll(type: Delete) { | |
dependsOn deleteBuildDirs, deleteEmptyDirs, deleteIdeaFiles | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment