Gradle task to create a zip archive of a directory

2019-02-06 04:39发布

问题:

I have a gradle task to create a zip archive of a directory. The gradle task is:

task archiveReports(type: Zip) {
   from '/projects/Reports/*'
   archiveName 'Reports.zip'
}

When I am running the command 'gradle archiveReports', its showing the build is successful. However, no zip file is getting created.

Am I missing something here?

回答1:

I figured out a way for this: Its working for me now.

task myZip(type: Zip) {
   from 'Reports/'
   include '*'
   include '*/*' //to include contents of a folder present inside Reports directory
   archiveName 'Reports.zip'
   destinationDir(file('/dir1/dir2/dir3/'))
}