Skip to content

Instantly share code, notes, and snippets.

@Leialoha
Last active December 16, 2023 08:10
Show Gist options
  • Save Leialoha/18b0909315436949d0cd4580254e68df to your computer and use it in GitHub Desktop.
Save Leialoha/18b0909315436949d0cd4580254e68df to your computer and use it in GitHub Desktop.
If you can't seem to run `gradle clean`, you might want to use this and replace the `**/expanded.lock` with the problem file.
// Removing all files but the expanded.lock
task customClean(type: Delete) {
// Specify the files or directories to delete
// delete 'otherDirectory'
// Remove all files except that one lock file
def files = []
fileTree("build")
.exclude('**/expanded.lock')
.visit { FileVisitDetails fvd ->
files << fvd.file
}
files.reverse()
.each { f ->
def file = file(f)
if (!file.exists()) return;
if ((file.isDirectory() && file.list().size() == 0)
|| !file.isDirectory())
delete f
}
}
clean.dependsOn customClean
clean.enabled = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment