Adrian Rus
Adrian Rus

Reputation: 359

Gradle zip task ignores files having filename starting with .#

I have a simple gradle zip task, I found out any files starting with .# from input folder are ignored

task zipIt(type: Zip) {
   from 'input/'
   archiveName = 'output.zip'
}

Does someone knows why is so? And how can I override this behavior so I include those files in the zip?

Later edit: Adding the file pattern explicitly doesn't seem to help

On the other hand, looking over @opal links led me to a solution:

import org.apache.tools.ant.DirectoryScanner

task zipIt(type: Zip) {
    doFirst{
        DirectoryScanner.removeDefaultExclude("**/.#*")
   }
   from 'input/'
   archiveName = 'output.zip'
}

Upvotes: 3

Views: 736

Answers (2)

Nathan
Nathan

Reputation: 3200

Expounding on Opal's answer, Gradle uses ANT's default excludes which are as follows:

As of Ant 1.8.1 they are:

 **/*~
 **/#*#
 **/.#*
 **/%*%
 **/._*
 **/CVS
 **/CVS/**
 **/.cvsignore
 **/SCCS
 **/SCCS/**
 **/vssver.scc
 **/.svn
 **/.svn/**
 **/.DS_Store

Ant 1.8.2 adds the following default excludes:

 **/.git
 **/.git/**
 **/.gitattributes
 **/.gitignore
 **/.gitmodules
 **/.hg
 **/.hg/**
 **/.hgignore
 **/.hgsub
 **/.hgsubstate
 **/.hgtags
 **/.bzr
 **/.bzr/**
 **/.bzrignore

The .# is by default excluded. Updating your build.gradle file with a task similar to the following should allow you to overwrite the default excludes.

task copyPoundFiles(type: Copy) {
  from '/path/to/files'
  into '/dest/for/files'
  include '**/.#*'
}

Upvotes: 2

Opal
Opal

Reputation: 84784

As far as I remember gradle used the same default excludes as ant does. Have you tried including the file explicitly?

Please have some further reading here and here.

Upvotes: 1

Related Questions