Deleting directories via gradle FileTree.include -
Deleting directories via gradle FileTree.include -
i want say:
clean.delete(filetree("a") { include "subdir/" include "afile" })
to delete directory "subdir" , file "afile". "subdir" not deleted. list explicitly:
clean.delete("a/subdir")
but more repetitious like. can filetree.include made job?
so far have come with:
[ "subdir", "afile", ... ].each { -> clean.delete("a/$it") }
but bit awkward.
i afraid not possible. see discussion on gradle forum. give-and-take lead issue.
a simple test shows
task makedir << { ['a', 'a/subdir'].each { new file(it).mkdirs() } new file('a/afile').createnewfile() def tree = filetree('a') { include 'subdir/' include 'afile' } tree.each {file file -> println file } }
prints file , not directory, directory traversed. solution save chars:
[ "subdir", "afile", ... ].each { clean.delete("a/$it") }
so filetree files in directory tree , not directories.
gradle
Comments
Post a Comment