Q:

Deleting directories via gradle FileTree.include

I want to say:
clean.delete(fileTree("a") {
   include "subdir/"
   include "aFile"
})

to delete the directory "subdir" and the file "aFile".  But "subdir" is not deleted.  I could list it explicitly:
clean.delete("a/subdir")

but that is more repetitious than I would like.  Can fileTree.include be made to do this job?
So far I have come up with:
[ "subdir",
  "aFile",
  ...
].each { it -> 
   clean.delete("a/$it") 
}

but that is just a bit awkward.

A:

I am afraid this is not possible. See this discussion on the gradle forum. The discussion lead to this 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 only the file and not the directory, as the directory is traversed. Your solution is good but you could save some chars:
[ "subdir",
  "aFile",
  ...
].each { clean.delete("a/$it") }

So fileTree is just for files in a directory tree and not for directories.

