Skip to content

Instantly share code, notes, and snippets.

@saw303
Created December 1, 2014 07:22
Show Gist options
  • Save saw303/b7c52934f0b035bd435b to your computer and use it in GitHub Desktop.
Save saw303/b7c52934f0b035bd435b to your computer and use it in GitHub Desktop.
This script deletes all folders in the local Gradle cache that version is lower than a specific one
def baseName = '3.05.BUILD-'
def version = '161'
def composedName = "${baseName}${version}"
def rootDir = new File('/home/saw/.gradle/caches/artifacts-24/filestore/com.adcubum.syrius')
assert rootDir.exists() && rootDir.canWrite()
def killList = []
rootDir.eachDirRecurse { dir ->
if (dir.name.startsWith(baseName) && dir.name.split('-')[1].toInteger() < version.toInteger()) {
println "KILL THAT PIECE ${dir.absolutePath}"
killList << dir
}
else {
//println "SKIP ${dir.name}"
}
}
killList.each { dir -> dir.deleteDir() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment