Skrypt czyszczący projekty w workspace-ach Eclipse który uruchamiam automatycznie przed każdym backupem
def path = '/Users/Jarek/Code/Eclipse/Workspaces' def isProject = ~/.*\.project/ def dryRun = false def timeIt = {String message, Closure cl -> def startTime = System.currentTimeMillis() cl() def deltaTime = System.currentTimeMillis() - startTime println "$message: \t: $deltaTime ms" } def toRemove = [] new File(path).eachDirRecurse { dir-> dir.eachFileMatch(isProject) { f -> def cp = new File(dir, '.classpath') if(cp.exists()) { def classpath = new XmlSlurper().parse(cp) def bins = classpath.classpathentry. findAll { it.@kind == 'output' }. collect { new File(dir, it.@path.text()) }. findAll { it.exists() } toRemove.addAll bins } } } if(dryRun) { println 'Removing (dry run)' println '------------------' toRemove.each { println it.getPath() } } else { println 'Removing' println '--------' toRemove.each { f-> timeIt("${f.getPath()}") { f.deleteDir() } } } echo 'Done'
Reklamy