Gradle task to create a zip archive of a directory

后端 未结 2 1683
孤街浪徒
孤街浪徒 2020-12-24 13:05

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

task archiveReports(type: Zip) {
   from \'/projects/Reports/*\'
   archiveN         


        
相关标签:
2条回答
  • 2020-12-24 13:38

    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/'))
    }
    
    0 讨论(0)
  • 2020-12-24 13:40

    Adding to the accepted answer, with Gradle 6.7,

    task packageDistribution(type: Zip) {
        archiveFileName = "my-distribution.zip"
        destinationDirectory = file("$buildDir/dist")
    
        from "$buildDir/toArchive"
    }
    

    archiveName is deprected.

    0 讨论(0)
提交回复
热议问题