Exclude folder in gradle zip task

Viewed 4896

I have a gradle zip task that looks like this:

task makeZipDev(type: Zip){
  from 'solr_config/solr_home'
  excludes  ['*/shop/product/data/' ]
  archiveName 'solr-home.zip'
  destinationDir(file('/docker/solr-dev/'))
}

I want to exclude everything the whole */shop/product/data/ folder from being zipped. And using excludes, as specified.

2 Answers

This is the way to go:

task makeZipDev(type: Zip){
  from 'solr_config/solr_home'
  exclude '**/shop/product/data/**'
  archiveName 'solr-home.zip'
  destinationDir(file('/docker/solr-dev/'))
}

or

task makeZipDev(type: Zip){
  from 'solr_config/solr_home'
  excludes = ['**/shop/product/data/**']
  archiveName 'solr-home.zip'
  destinationDir(file('docker/solr-dev/'))
}

Also, are you sure about destinationDir path? It starts under root?

    task backupG (type: Zip){
    archiveFileName = "myfiles.zip"
    destinationDir = file('D:\\cb\\OnADrive\\')

    from ('D:\\cb\\gd\\') {
        excludes = ['D:\\cb\\gd\\Presentations\\**', 'D:\\cb\\gd\\Tech Docs\\**']
    }
    doFirst{ println("Starting to copy to archieve...") }
    doLast{ println("Done archiving...") } 
}

The above code is not excluding the "Presentations" or "Tech Docs".

Related