How to delete an empty directory (or the directory with all contents recursively) in gradle?

前端 未结 6 1462
后悔当初
后悔当初 2020-12-15 18:10

I can\'t figure out how to delete all contents of a directory.

For cleaning out a directory, I want to remove all files and directories inside it: I want to wipe ev

6条回答
  •  天命终不由人
    2020-12-15 18:50

    Following will delete all content from the src folder but leaves the folder itself untouched:

    task deleteGraphicsAssets(type: Delete) {
        def dirName = "src" 
        file( dirName ).list().each{
            f -> 
                delete "${dirName}/${f}"
        }
    }
    

提交回复
热议问题