Note: This is just a quickly hacked together task
To Use:
- Paste the task below in a gradle build file
- Call
gradle invalidate -Pdependency=group:name:versionsubstituting the dependency you want to invalidate.
| task invalidate() { | |
| doLast { | |
| def depPath | |
| if (project.hasProperty('dependency')) { | |
| depPath = dependency.replace(':','/') | |
| } else { | |
| logger.error("Please pass a dependency to invalidate. Ex: gradle invalidate -Pdependency=group:name:version") | |
| } | |
| configurations.all.each { conf -> | |
| conf.each { file -> | |
| def path = file.getCanonicalPath() | |
| if (path.contains(depPath) && file.exists()) { // Note: file could be listed multiple times | |
| logger.warn("Removing from cache: {}", path) | |
| file.delete() | |
| } | |
| } | |
| } | |
| } | |
| } |
In Module Level or Application level?